Class Object()
{
Public:
Object()
{
Prop1=”Arbitrary 1st property”;
}
Virtual void printAll()
{
Cout<<prop1<<” “<<prop2<<endl;
//when you extend object class modify function to print all
//properties
}
Virtual int print(string propertyToPrint)
{
If(propertytoPrint==”prop1”)
{
Cout<<prop1<<endl;
Return 1;
}
else
If(propertytoPrint==”prop2”)
{
Cout<<prop1<<endl;
Return 1;
}
Else
Return -1;
//when you extend object class add cases for all the various
//properties. Return a positive number in these cases
}
Virtual int set(string propertyToSet, string valueToSet)
{
If(propertytoSet==”prop1”)
{
Prop1= valueToSet;
Return 1;
}
Else
If(propertytoSet==”prop2”)
{
valueToSet = atoi(propertyToSet.c_str());
if(valueToset==0)
return -1;
Prop1= valueToSet;
Return 1;
}
Else
Return -1;
//when you extend object class add cases for all the various
//properties. Return a positive number in these cases
}
Private:
String prop1;
Int prop2;
}
Class Console
{
Public:
Console(Object object)
myObject = object;
Void run()
While(true)
{
cout << "Enter a command \n>";
Cin>>command;
If(command==”GET”)
Cin>>param1;//should be a propertyname or *
If(param1==”*”)
{
[Link]();
}
Else
{
Int confirm2=[Link](param1);
If(confirm==-1)
Cout<<” nonexistent variable”<<endl;
}
Else
If(command==”SET”)
Cin<<argument;
Int equalsInd= argument.find_first_of(‘=’);
Param1=[Link](0,equalsInd);
Param2 = [Link](equalsind +1, [Link]-
([Link]+1));
Int confirm=[Link](param1,param2);
If(confirm==-1)
Cout<<”Invalid conversion or nonexistent
variable”<<endl;
//Dans=a ind of equalsis 4
}
else
Cout<<”Invalid command”<<endl;
}
Private:
String command,argument, param1, param2;
Object myObject;