Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. /* In main would be something for user input of brand, material, age, price, cost.
  10. Separate function outside of classes to determine what class watch falls under
  11.  
  12. Priority given to if price > $800
  13. */
  14.  
  15. class Watch{
  16. //variables from main()
  17. string brand;
  18. int material; //gold = 1, silver = 2
  19. int age;
  20. float price; //watch price
  21. float cost; //repair cost
  22.  
  23. public:
  24. virtual void get_cost()
  25. };
  26.  
  27. class Designer: public Watch
  28. {
  29. int repair_factor;
  30.  
  31. //material set to 1 = gold, 2 = silver (assuming a menu function exists elsewhere)
  32. if (material == 1)
  33. {
  34. repair_factor = 4;
  35. }
  36. else if(material == 2)
  37. {
  38. repair_factor = 3;
  39. }
  40.  
  41. public:
  42. void get_cost(){
  43. cost = price/repair_factor;
  44. }
  45.  
  46. class Nondesigner: public Watch
  47. {
  48. vector<string> free_list;
  49. ifstream listFile("freelist.txt");
  50. string line;
  51.  
  52. while(getline(listFile, line))
  53. {
  54. string new_line;
  55. new_line = line;
  56. cout<< new_line;
  57. free_list.push_back(new_line);
  58. }
  59.  
  60. bool free()
  61. {
  62. int i, result;
  63.  
  64. for(i = 0; i < free_list.size(); i++)
  65. {
  66. result = strcmp(brand, free_list[i]);
  67. if(result)
  68. {
  69. break;
  70. }
  71. }
  72. return result;
  73. }
  74.  
  75. public:
  76. void get_cost()
  77. {
  78. if(!free)
  79. {
  80. cost = price*.15;
  81. }
  82. else
  83. {
  84. cost = 0;
  85. }
  86. }
  87. }
  88.  
  89. class Antique: public Watch
  90. {
  91. public:
  92. void get_cost()
  93. {
  94. cost = age/2;
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement