Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Invoice
- {
- public:
- void setPartNumber (string number)
- {
- product = number;
- }
- string getPartNumber()
- {
- return product;
- }
- void setPartDescription (string desc)
- {
- description = desc;
- }
- string getPartDescription()
- {
- return description;
- }
- void setQuantityPurchased (int amount)
- {
- quantity = amount;
- }
- int getQuantityPurchased()
- {
- return quantity;
- }
- void setPriceItem (float price)
- {
- prices = price;
- }
- float getPriceItem()
- {
- return prices;
- }
- void getInvoiceAmount()
- {
- float total = quantity * prices;
- cout << "Producto#: " << getPartNumber() << "\nDescripcion: " << getPartDescription() << "\nCantidad: " << getQuantityPurchased() << "\nPrecio: " << getPriceItem() << "\nSu total: " << total << endl;
- }
- private:
- int quantity;
- float prices;
- string product;
- string description;
- };
- int main()
- {
- Invoice invoice1;
- Invoice invoice2;
- //this is a test to set invoice1
- invoice1.setPartDescription("A wrench");
- invoice1.setPartNumber("12345");
- invoice1.setPriceItem(4.99);
- invoice1.setQuantityPurchased(5);
- //this outputs invoice1
- invoice1.getInvoiceAmount();
- //this is a test to set invoice2
- invoice2.setPartDescription("A nail");
- invoice2.setPartNumber("111");
- invoice2.setPriceItem(.99);
- invoice2.setQuantityPurchased(75);
- //this outputs invoice2
- invoice2.getInvoiceAmount();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement