typedef short unsigned int USHORT;
void build();
void total();
void exitpro();
int exit = 0;
class computer
{
private:
USHORT Monitor; //1
USHORT Cpu; //2
USHORT Ram; //3
USHORT Hd; //4
USHORT Fd; //5
USHORT Case; //6
USHORT Cd; //7
USHORT Mobo; //8
USHORT Sc; //9
USHORT Md; //10
USHORT Vc; //11
USHORT Cables; //12
USHORT Spkr; //13
public:
void Change_Class(int, int);
};
void computer::Change_Class(int com, int cost)
{
if (com == 1)
Monitor = cost;
if (com == 2)
Cpu = cost;
if (com == 3)
Ram = cost;
if (com == 4)
Hd = cost;
if (com == 5)
Fd = cost;
if (com == 6)
Case = cost;
if (com == 7)
Cd = cost;
if (com == 8)
Mobo = cost;
if (com == 9)
Sc = cost;
if (com == 3)
Md = cost;
if (com == 3)
Vc = cost;
if (com == 3)
Cables = cost;
if (com == 3)
Spkr = cost;
else
{
cout << "Error#3:INVALID INT AT 'void computer::Change_Class(int com, int cost)'
";<br>
exitpro();
}
}
void main()
{
USHORT Menu;
do
{
cout << "Welcome to Price machine version 2.0.
";<br>
cout << "This program uses classes in place of 300 int's
";<br>
cout << "Main menu:
1=Build new computer
2=Show total
3=Exit
";<br>
cout << "Enter a number: ";<br>
cin >> Menu;
if(Menu == 1)
void build();
if(Menu == 2)
void total();
if(Menu == 3)
exitpro();
else
{
cout << "Error#1
";<br>
void exitpro();
}
}
while(exitpro == 0);
}
void build()
{
computer MyComp;
int mon, cpu, ram, cdd, cse, mdm, snd, vdc, spk, fdd, hdd, mbo, cbl;
cout << "Enter your monitor
";<br>
cout << "1=mon1
2=mon2";<br>
cin >> mon;
if(mon == 1)
MyComp.Change_Class(1, 100);
if(mon == 2)
MyComp.Change_Class(1, 200);
else
{
void exitpro();
}
cout << "Enter your CPU
";<br>
cout << "1=cpu1
2=cpu2";<br>
cin >> cpu;
if(cpu == 1)
MyComp.Change_Class(2, 300);
if(mon == 2)
MyComp.Change_Class(2, 400);
else
{
void exitpro();
}
}
void exitpro()
{
exit = 1;
}
It looks like you're new here. If you want to get involved, click one of these buttons!