Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Invoice
  6. {
  7. public:
  8. void setPartNumber (string number)
  9. {
  10. product = number;
  11. }
  12. string getPartNumber()
  13. {
  14. return product;
  15. }
  16. void setPartDescription (string desc)
  17. {
  18. description = desc;
  19. }
  20. string getPartDescription()
  21. {
  22. return description;
  23. }
  24. void setQuantityPurchased (int amount)
  25. {
  26. quantity = amount;
  27. }
  28. int getQuantityPurchased()
  29. {
  30. return quantity;
  31. }
  32. void setPriceItem (float price)
  33. {
  34. prices = price;
  35. }
  36. float getPriceItem()
  37. {
  38. return prices;
  39. }
  40. void getInvoiceAmount()
  41. {
  42. float total = quantity * prices;
  43. cout << "Producto#: " << getPartNumber() << "\nDescripcion: " << getPartDescription() << "\nCantidad: " << getQuantityPurchased() << "\nPrecio: " << getPriceItem() << "\nSu total: " << total << endl;
  44. }
  45. private:
  46. int quantity;
  47. float prices;
  48. string product;
  49. string description;
  50. };
  51.  
  52.  
  53. int main()
  54. {
  55. Invoice invoice1;
  56. Invoice invoice2;
  57.  
  58. //this is a test to set invoice1
  59. invoice1.setPartDescription("A wrench");
  60. invoice1.setPartNumber("12345");
  61. invoice1.setPriceItem(4.99);
  62. invoice1.setQuantityPurchased(5);
  63.  
  64. //this outputs invoice1
  65. invoice1.getInvoiceAmount();
  66.  
  67. //this is a test to set invoice2
  68. invoice2.setPartDescription("A nail");
  69. invoice2.setPartNumber("111");
  70. invoice2.setPriceItem(.99);
  71. invoice2.setQuantityPurchased(75);
  72.  
  73. //this outputs invoice2
  74. invoice2.getInvoiceAmount();
  75.  
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement