Professional Documents
Culture Documents
Furniture String
Furniture String
#include <stdlib.h>
#include<string>
using namespace std;
class Furniture {
private:
string name;
float price;
public:
Furniture() : name(""), price() {}
Furniture(string c_name, float c_price) :
name(c_name),
price(c_price) {}
void setData()
{
string c_name;
float c_price;
cin.ignore();
cout << "Furniture name: "; getline(cin, c_name);
this->SetName(c_name);
cout << "Enter price: "; cin >> c_price;
this->SetPrice(c_price);
}
void displayData()
{
cout << "Furniture name: " << this->GetName() << endl;
cout << "Price: " << this->GetPrice() << endl;
}
string GetName()
{
return this->name;
}
float GetPrice()
{
return this->price;
}
};
void setData()
{
string c_colour;
cin.ignore();
cout << "Colour: "; getline(cin, c_colour);
this->SetColour(c_colour);
}
void displayData()
{
cout << "Colour: " << this->GetColour() << endl;
}
};
void setData()
{
int c_count_on_table;
cout << "Table count: "; cin >> c_count_on_table;
this->SetCountTable(c_count_on_table);
}
void displayData()
{
cout << "Table count: " << this->GetCountTable() << endl;
}
int main()
{
char operation;
Table tables[10];
Chair chairs[10];
int cout = 0;
do {
std::cout << "\n MENU\n";
std::cout << "1-Get Data: \n";
std::cout << "2-Display data\n";
std::cout << "\n Chose or cancel by pressing 0\n";
cin >> operation;
switch (operation)
{
case'0':break;
case'1':tables[cout++].setData(); chairs[cout].setData(); break;
case'2':std::cout << "Display data\n";
for (int i = 0; i < cout; i++)
{
chairs[i].displayData();
tables[i].displayData();
}
break;
default:
break;
}
} while (operation != '0');
return 0;
}
};