Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
gnumch.ExpressionLevelset Class Reference
Inheritance diagram for gnumch.ExpressionLevelset:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def getError
def getNumberWithAnswer
def getPlus
def getMinus
def getTimes
def getDivide

Public Attributes

 numlevels
 num_sublevels
 levelops
 curlevel
 cur_sublevel

Detailed Description

Definition at line 222 of file gnumch.py.


Constructor & Destructor Documentation

Reimplemented in gnumch.EqualityLevelset.

Definition at line 223 of file gnumch.py.

00223 
00224     def __init__(self):
00225         self.numlevels = 7
00226         self.num_sublevels = 7
00227         self.levelops = [ [self.getPlus],
00228                           [self.getMinus],
00229                           [self.getPlus, self.getMinus],
00230                           [self.getTimes],
00231                           [self.getPlus, self.getMinus, self.getTimes],
00232                           [self.getDivide],
00233                           [self.getPlus, self.getMinus, self.getTimes, self.getDivide]
00234                         ]
00235         self.curlevel = 1
00236         self.cur_sublevel = 1


Member Function Documentation

def gnumch.ExpressionLevelset.getDivide (   self,
  answer 
)

Definition at line 261 of file gnumch.py.

00261 
00262     def getDivide(self, answer):
00263         n = random.randint(1, 5)
00264         return Number( _(u'%d \u00f7 %d') % (answer*n, n), 1 )

def gnumch.ExpressionLevelset.getError (   self,
  num 
)

Definition at line 237 of file gnumch.py.

00237 
00238     def getError(self, num):
00239         fmt = _('%s = %d')
00240         return fmt % (num.text, num.value)

def gnumch.ExpressionLevelset.getMinus (   self,
  answer 
)

Definition at line 252 of file gnumch.py.

00252 
00253     def getMinus(self, answer):
00254         n = random.randint(answer, answer*2)
00255         num = Number( _(u'%d \u2212 %d') % (n, n-answer), 1 )
00256         return num

def gnumch.ExpressionLevelset.getNumberWithAnswer (   self,
  answer 
)

Definition at line 241 of file gnumch.py.

00241 
00242     def getNumberWithAnswer(self, answer):
00243         fn = random.choice( self.levelops[self.curlevel-1] )
00244         num = fn(answer)
00245         num.value = answer
00246         return num

Here is the caller graph for this function:

def gnumch.ExpressionLevelset.getPlus (   self,
  answer 
)

Definition at line 247 of file gnumch.py.

00247 
00248     def getPlus(self, answer):
00249         n = random.randint(0, answer)
00250         num = Number( _(u'%d + %d') % (n, answer-n), 1 )
00251         return num

def gnumch.ExpressionLevelset.getTimes (   self,
  answer 
)

Definition at line 257 of file gnumch.py.

00257 
00258     def getTimes(self, answer):
00259         n = random.choice( getFactors(answer) )
00260         return Number( _(u'%d \u00d7 %d') % (n, answer/n), 1 )

Here is the call graph for this function:


Member Data Documentation

Reimplemented in gnumch.EqualityLevelset.

Definition at line 235 of file gnumch.py.

Reimplemented in gnumch.EqualityLevelset.

Definition at line 234 of file gnumch.py.

Definition at line 226 of file gnumch.py.

Definition at line 225 of file gnumch.py.

Definition at line 224 of file gnumch.py.


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