Open main menu

CDOT Wiki β

Changes

OOP344 Assignment Two

1,268 bytes added, 22:22, 18 October 2009
IO_Field
As the first part of your project this semester, you are to create few classes to encapsulate [[OOP344 Assignment One|Console Input Output Library]]
===IO_Field===
 
'''IO_Field''' is the base class for all different types of Fields on a Form.
<big><pre>
class IO_Form; // forward declaration
class IO_Field{
protected:
void* _data;
int _row;
int _col;
public:
IO_Field(int row, int col);
void* Data();
virtual void Display() = 0;
virtual int Edit(IO_Form *Owner=NULL)= 0;
virtual bool Editable() = 0;
virtual void Set(const void *) = 0;
virtual ~IO_Field();
};
</pre></big>
 
'''IO_Field(int row, int col);'''
 
This constructor set the corresponding attributes to the values of incoming arguments and sets the data attribute to NULL.
'''void* Data();'''
 
Returns the value of the data attribute.
 
'''virtual ~IOField();'''
 
An empty destructor (the body of the method is blank)
 
'''virtual void Display() = 0;'''<br />
'''virtual int Edit(Screen *Owner=NULL)= 0;'''<br />
'''virtual bool Editable() = 0;'''<br />
'''virtual void Set(const void *) = 0;'''<br />
 
 
These are pure virtual methods enforcing the creation of the identical methods in the derived classes. This make the IO_Field class an abstract class.
Note: The purpose of passing a IO_Form pointer to the Edit method, is to make the future Edit methods capable of sending a message (errors and help messages)to the Screen they are being Edited on.
 
===IO_Frame===