سلام دوستان
پاسخ پروژه برنامه نویسی فصل 4 کتاب جعفر نژاد قمی C++‎
کلاسی به نام invoice برای یک فروشگاه قطعات سخت افزاری بنویسید

#include"stdafx.h"
#include<iostream>
#include<string>
using namespace std;
class invoice
{
public:
void Menu();
invoice();//baray dadn meghadr avalie be mothghair ha
void setnumpice();//baray taein tedad ghate
void getnumpice();//darayf tedad ghate.
void ScreenDisplay();//namayesh nahaei
void WorngEnter();//vorodi Eshtebah
private:
string NamePice;//esm ghate
string AboutPice;
int TedadGhatat;
int hazineKol;
int ghimatghete;
char np;
};
invoice::invoice()
{
ghimatghete = 0;
hazineKol = 0;
NamePice = "HICH";
AboutPice = "Cpu";
TedadGhatat = 3;
}
void invoice::Menu()
{
cout << " >>>>>>>>>>>>>>HellO<<<<<<<<<<<<<<<"<<endl;
cout << " Welcome to Shop " << endl<<endl;
cout << "List Ghatat" << endl;
cout<< " 1.Cpu === Ghimat:50000"<<endl;
cout << " 2.Graphic === Ghimat:40000"<<endl;
cout << " 3.Ram === Ghimat:30000"<<endl;
cout << " 4.Power === Ghimat:20000"<<endl;
cout << "\n";
cout << "Moshtari Gerami Baray Kharid Kalay Khod Nam ghete mord niaz khod ra benevisid "<<endl;
getline(cin,NamePice);
if (NamePice == "CPU" || NamePice == "cpu" || NamePice == "Cpu")
{
ghimatghete = 50000;
setnumpice();
}
else if (NamePice == "Graphic" || NamePice == "graphic")
{
ghimatghete = 40000;
setnumpice();
}
else if (NamePice == "Ram" || NamePice == "ram")
{
ghimatghete = 30000;
setnumpice();

}
else if (NamePice == "Power" || NamePice == "power")
{
ghimatghete = 20000;
setnumpice();
}
else if (NamePice != "Power" && NamePice != "power" && NamePice != "Ram" && NamePice != "ram" && NamePice != "Graphic" && NamePice != "graphic" && NamePice != "CPU" && NamePice != "cpu" && NamePice != "Cpu")
WorngEnter();
}
void invoice::setnumpice()
{


cout << "Ghate Mord Nazar Shoma " << NamePice << " Mibashad Az in ghete che tedad mikhahid"<<endl;
getnumpice();
}
void invoice::getnumpice()
{
cin >> TedadGhatat;
if (TedadGhatat < 0)
TedadGhatat = 0;
hazineKol = TedadGhatat*ghimatghete;
ScreenDisplay();
}
void invoice::WorngEnter()//for Worng Type
{
cout << "GHete VORODI MOJOD NIST" << endl;
cout << "Agar Mikhahid Ghete Digar Entekhab Konid Adad 1 Ra vared Konid Baray khoroj 2 Ra vared Konid"<<endl;
cin.get();
if (cin.get() == 1)
Menu();
else
{
cin.get();
}




}
void invoice::ScreenDisplay()
{
cout << "Moshakhast Kharid Shoma"<<endl;
cout << "NamGhete == " << NamePice<<endl;
cout << "Ghimat yek Vahed Ghete==" << ghimatghete<<endl;
cout << "TEdad Darkhasti==" << TedadGhatat<<endl;
cout << "Majmooe Kol==" << hazineKol<<endl;
}
int main()
{
invoice Darkhast;
Darkhast.Menu();
cin.get();
cin.ignore();
return 0;
}