1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| #include <iostream>
#include <string>
#define TAXES 0.2
using namespace std;
class Article
{
protected:
int number;
int quantity;
string name;
float price; //it is the price without the taxes
public:
Article(int number, int quantity, string name, float price);
virtual void display();
virtual float setPriceWithTaxes(); //it will give us the price with taxes
};
Article::Article(int aNumber, int aQuantity, string aName, float aPrice)
{
number = aNumber;
quantity = aQuantity;
name = aName;
price = aPrice;
}
void Article::display()
{
cout << "The article number is " << number << endl;
cout << "We have " << quantity << " of this article in our stock" << endl;
cout << "The name of the article is " << name << endl;
cout << "The price of this article without taxes is " << price << " euros" <<endl;
}
float Article::setPriceWithTaxes()
{
float newPrice;
newPrice = price+(price*TAXES);
cout << "The price of this article with taxes is " << newPrice << " euros" << endl;
}
class Clothe : public Article
{
string sizeClothe; //Size are from XS to XL
string colorClothe;
public:
Clothe(int number,int quantity,string name,float price,string sizeClothe, string colorClothe);
virtual void display();
};
Clothe::Clothe(int aNumber,int aQuantity,string aName,float aPrice,string aSizeClothe,string aColorClothe): Article(number,quantity,name,price)
{
sizeClothe=aSizeClothe;
colorClothe=aColorClothe;
}
void Clothe::display()
{
Article::display();
cout << "The size of the clothe is " << sizeClothe << endl;
cout << "The color of the clothe is " << colorClothe << endl;
}
int main()
{
Article femaleArticle = Article(1250369,10,"Maxi Dress",25.99);
femaleArticle.display();
femaleArticle.setPriceWithTaxes();
Article maleArticle = Article(1236501,5,"Sweatshirt",35.99);
maleArticle.display();
Clothe dress = Clothe(1265879,2,"Wedding Dress",1250.90,"S","White");
dress.display();
return 0;
} |
Partager