Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <stdio.h>
- #include <string.h>
- #include <vector>
- using namespace std;
- /* In main would be something for user input of brand, material, age, price, cost.
- Separate function outside of classes to determine what class watch falls under
- Priority given to if price > $800
- */
- class Watch{
- //variables from main()
- string brand;
- int material; //gold = 1, silver = 2
- int age;
- float price; //watch price
- float cost; //repair cost
- public:
- virtual void get_cost()
- };
- class Designer: public Watch
- {
- int repair_factor;
- //material set to 1 = gold, 2 = silver (assuming a menu function exists elsewhere)
- if (material == 1)
- {
- repair_factor = 4;
- }
- else if(material == 2)
- {
- repair_factor = 3;
- }
- public:
- void get_cost(){
- cost = price/repair_factor;
- }
- class Nondesigner: public Watch
- {
- vector<string> free_list;
- ifstream listFile("freelist.txt");
- string line;
- while(getline(listFile, line))
- {
- string new_line;
- new_line = line;
- cout<< new_line;
- free_list.push_back(new_line);
- }
- bool free()
- {
- int i, result;
- for(i = 0; i < free_list.size(); i++)
- {
- result = strcmp(brand, free_list[i]);
- if(result)
- {
- break;
- }
- }
- return result;
- }
- public:
- void get_cost()
- {
- if(!free)
- {
- cost = price*.15;
- }
- else
- {
- cost = 0;
- }
- }
- }
- class Antique: public Watch
- {
- public:
- void get_cost()
- {
- cost = age/2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement