Python_2  1.0
Public Member Functions | Public Attributes | List of all members
_01e_fracoes.Fracoes Class Reference

Process fractions on a given file. More...

Public Member Functions

def __init__ (self, filename)
 Constructor. More...
 
def Reader (self, f)
 Reads a file with a numerator (int) and denominator (int) per line. More...
 
def __getitem__ (self, i)
 Returns the ith fraction. More...
 
def __setitem__ (self, i, f)
 Sets the ith fraction to f. More...
 
def __str__ (self)
 Returns the sum and product of all entries of "lfracoes". More...
 
def __repr__ (self)
 Returns each fraction in list "lfracoes". More...
 

Public Attributes

 lfracoes
 A list, which aggregates objects of type Fracao. More...
 

Detailed Description

Process fractions on a given file.

Constructor & Destructor Documentation

◆ __init__()

def _01e_fracoes.Fracoes.__init__ (   self,
  filename 
)

Constructor.

Opens filename and calls Reader for inputting the fraction readings. Raises an exception if filename does not exist.

Parameters
filenamefraction file name.

Member Function Documentation

◆ __getitem__()

def _01e_fracoes.Fracoes.__getitem__ (   self,
  i 
)

Returns the ith fraction.

Parameters
iindex.

References _01e_fracoes.Fracoes.lfracoes.

◆ __repr__()

def _01e_fracoes.Fracoes.__repr__ (   self)

Returns each fraction in list "lfracoes".

Returns
a string: a series of fractions, one per line.

◆ __setitem__()

def _01e_fracoes.Fracoes.__setitem__ (   self,
  i,
  f 
)

Sets the ith fraction to f.

Parameters
iindex.
fa fraction object.

References _01e_fracoes.Fracoes.lfracoes.

◆ __str__()

def _01e_fracoes.Fracoes.__str__ (   self)

Returns the sum and product of all entries of "lfracoes".

Returns
a string: sum and product of all fractions.

References _01e_fracoes.Fracoes.lfracoes.

◆ Reader()

def _01e_fracoes.Fracoes.Reader (   self,
  f 
)

Reads a file with a numerator (int) and denominator (int) per line.

Creates a Fracao object for each line and inserts it in the lfracoes list.

Parameters
ffraction file object.

References _01e_fracoes.Fracoes.lfracoes.

Member Data Documentation

◆ lfracoes

_01e_fracoes.Fracoes.lfracoes

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