You are on page 1of 2

// ConsoleApplication2.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;

class Shirt
{
private:
char size;
char color;
string design;
public:

void set_size(char isze)


{
if (isze == 'L' || isze == 'M' || isze == 'S')
size = isze;
else
cout << "Wrong Size! \n";
}

void set_color(char iclr)


{
if (iclr == 'B' || iclr == 'W')
color = iclr;
else
cout << "Wrong color \n";
}

double price()
{
double prc = 0;
switch (size)
{
case 'L':
case 'l':
prc = 20;
break;
case 'M':
case 'm':
prc = 10;
break;
case 'S':
case 's':
prc = 5;
break;
default:
cout << "Wrong choice \n";
}

if ((size == 'M' || size =='m') && (color == 'W' || color == 'w'))


prc = prc + 5;

return prc;
}

void set_design(int desig)


{
string one("TeeJays");
string two("JJs");
if (desig == 1)
design = one;
else if (desig == 2)
design = two;
else cout << "Wrong selection";
}

};

int _tmain(int argc, _TCHAR* argv[])


{
afc:
int numshirts, count, design_no;
Shirt *all_shirts;
char shirt_size, shirt_color;
double total =0.0 ;

cout << "How many shirts do you want?";


cin >> numshirts;

all_shirts = new Shirt[numshirts];

for (count = 0; count < numshirts; count++)


{
cout << "Enter Shirt " << (count + 1) << " size S, M, L : ";
cin >> shirt_size;
all_shirts[count].set_size(shirt_size);

cout << "Enter Shirt " << (count + 1) << " Color B, W : ";
cin >> shirt_color;
all_shirts[count].set_color(shirt_color);

cout << "Enter Shirt " << (count + 1) << " design \n 1. Teejays 2. JJs : ";
cin >> design_no;
all_shirts[count].set_design(design_no);
}

for (int i = 0; i < numshirts; i++)


total += all_shirts[i].price();

cout << "\n\n\t Total Price for " << numshirts << " shirts is : " << total <<
"\t\n\n";

goto afc;

return 0;
}

You might also like