Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
gnumch.MultipleLevelset Class Reference

List of all members.

Public Member Functions

def __init__
def getError
def getTitle
def setLevel
def getNumber

Public Attributes

 numlevels
 num_sublevels
 min_mult
 curlevel
 cur_sublevel

Detailed Description

Definition at line 183 of file gnumch.py.


Constructor & Destructor Documentation

Definition at line 184 of file gnumch.py.

00184 
00185     def __init__(self):
00186         self.numlevels = 4
00187         self.num_sublevels = 9
00188         self.min_mult = 4
00189         self.curlevel = 1
00190         self.cur_sublevel = 1


Member Function Documentation

def gnumch.MultipleLevelset.getError (   self,
  num 
)

Definition at line 191 of file gnumch.py.

00191 
00192     def getError(self, num):
00193         fmt = _('%s are the factors of %d.')
00194         n = int(num.text)
00195 
00196         factors = []
00197         for i in range(1, n/2+1):
00198             if n % i == 0:
00199                 factors.append(i)
00200         factors.append(n)
00201         s = makeNumList(factors) % tuple(factors)
00202         return fmt % (s, n)

Here is the call graph for this function:

Definition at line 210 of file gnumch.py.

00210 
00211     def getNumber(self):
00212         if random.randint(0,1):
00213             # choose a good number
00214             n = (self.cur_sublevel+1) * random.randint(1, self.min_mult + self.curlevel*2)
00215             num = Number( str(n), 1 )
00216         else:
00217             # choose a wrong number
00218             n = (self.cur_sublevel+1) * random.randint(1, self.min_mult + self.curlevel*2) - random.randint(1, self.cur_sublevel)
00219             num = Number( str(n), 0 )
00220         return num
00221 
# for all expression-based levels, we add a value field to the Number

Definition at line 203 of file gnumch.py.

00203 
00204     def getTitle(self):
00205         return _('Multiples of %d') % ( self.cur_sublevel+1 )

def gnumch.MultipleLevelset.setLevel (   self,
  level,
  sublevel 
)

Definition at line 206 of file gnumch.py.

00206 
00207     def setLevel(self, level, sublevel):
00208         self.curlevel = level
00209         self.cur_sublevel = sublevel


Member Data Documentation

Definition at line 189 of file gnumch.py.

Definition at line 188 of file gnumch.py.

Definition at line 187 of file gnumch.py.

Definition at line 186 of file gnumch.py.

Definition at line 185 of file gnumch.py.


The documentation for this class was generated from the following file: