Back to index

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

List of all members.

Public Member Functions

def __init__
def getError
def getTitle
def setLevel
def getNumber

Public Attributes

 num_sublevels
 numlevels
 level_multiple
 curlevel
 cur_sublevel
 factors
 nonfactors

Detailed Description

Definition at line 139 of file gnumch.py.


Constructor & Destructor Documentation

Definition at line 140 of file gnumch.py.

00140 
00141     def __init__(self):
00142         self.num_sublevels = 9
00143         self.numlevels = 1
00144         self.level_multiple = [ 4, 6, 8, 10, 12, 15, 18, 20, 24 ]
00145         self.curlevel = 1
00146         self.cur_sublevel = 1
00147         self.factors = []
00148         self.nonfactors = []


Member Function Documentation

def gnumch.FactorLevelset.getError (   self,
  num 
)

Definition at line 149 of file gnumch.py.

00149 
00150     def getError(self, num):
00151         fmt = _('Multiples of %d include %s,\nbut %d is not a multiple of %d.')
00152         n = int(num.text)
00153         mults = []
00154         for i in range(2, 5):
00155             mults.append(n*i)
00156         s = makeNumList(mults) % tuple(mults)
00157         return fmt % (n, s, self.level_multiple[self.cur_sublevel-1], n)

Here is the call graph for this function:

Definition at line 172 of file gnumch.py.

00172 
00173     def getNumber(self):
00174         if random.randint(0,1):
00175             # choose a good number
00176             n = self.factors[ random.randint(0, len(self.factors)-1) ]
00177             num = Number( str(n), 1 )
00178         else:
00179             # choose a wrong number
00180             n = self.nonfactors[ random.randint(0, len(self.nonfactors)-1) ]
00181             num = Number( str(n), 0 )
00182         return num

Definition at line 158 of file gnumch.py.

00158 
00159     def getTitle(self):
00160         return _('Factors of %d') % ( self.level_multiple[self.cur_sublevel-1] )

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

Definition at line 161 of file gnumch.py.

00161 
00162     def setLevel(self, level, sublevel):
00163         self.curlevel = level
00164         self.cur_sublevel = sublevel
00165         self.factors = []
00166         self.nonfactors = []
00167         for i in range(1, self.level_multiple[sublevel-1]+1):
00168             if self.level_multiple[sublevel-1] % i == 0:
00169                 self.factors.append(i)
00170             else:
00171                 self.nonfactors.append(i)


Member Data Documentation

Definition at line 145 of file gnumch.py.

Definition at line 144 of file gnumch.py.

Definition at line 146 of file gnumch.py.

Definition at line 143 of file gnumch.py.

Definition at line 147 of file gnumch.py.

Definition at line 141 of file gnumch.py.

Definition at line 142 of file gnumch.py.


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