Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This compiles if all merged into one file, it also works with a makefile, unless I add #include "finance.h" and #include "freight.h" just below this line. Both of those classes that interact with nothing as of yet. Adding them to the includes and leaving part_time.h at the bottom breaks it, putting part_time.h at the top of the includes compiles.
- //main.cpp
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- #include <vector>
- #include "casual.h"
- #include "dockhand.h"
- #include "employee.h"
- #include "manager.h"
- #include "part_time.h"
- using namespace std;
- void add_casual()
- {
- string name;
- bool forklift;
- name = "bill";
- forklift = true;
- Casual casual(name, forklift);
- }
- void add_part_time()
- {
- string name;
- bool forklift;
- int annual_leave;
- int sick_leave;
- name = "Ben";
- forklift = false;
- annual_leave = 1;
- sick_leave = 2;
- Part_time part_time(name, forklift, annual_leave, sick_leave);
- }
- void add_dockhand()
- {
- int dock_type;
- dock_type = 1;
- if(dock_type == 1)
- {
- add_part_time();
- }
- else if(dock_type == 2)
- {
- add_casual();
- }
- else
- {
- cout << "Sorry. Your input is invalid." << endl;
- add_dockhand();
- }
- }
- void add_manager()
- {
- string name;
- name = "Bub";
- }
- int main()
- {
- cout << "Hello" << endl;
- }
- //casual.h
- #ifndef CASUAL
- #define CASUAL
- #include <string>
- #include "dockhand.h"
- using namespace std;
- class Casual: public Dockhand
- {
- public:
- Casual (string set_name, bool set_forklift);
- float min_shift;
- ~Casual();
- };
- #endif // CASUAL
- //casual.cpp
- #include "casual.h"
- Casual::Casual (string set_name, bool set_forklift) : Dockhand (set_name, set_forklift)
- {
- min_shift = 2.00;
- payrate = 26.00;
- }
- Casual::~Casual()
- {
- }
- //dockhand.h
- #ifndef DOCKHAND
- #define DOCKHAND
- #include <string>
- #include "employee.h"
- using namespace std;
- class Dockhand: public Employee
- {
- public:
- Dockhand (string set_name, bool set_forklift);
- float start_shift;
- bool forklift;
- float payrate;
- ~Dockhand();
- };
- #endif // DOCKHAND
- //dockhand.cpp
- #include "dockhand.h"
- Dockhand::Dockhand (string set_name, bool set_forklift) : Employee (set_name)
- {
- forklift = set_forklift;
- start_shift = 4.00;
- }
- Dockhand::~Dockhand()
- {
- }
- //employee.h
- #ifndef EMPLOYEE
- #define EMPLOYEE
- #include <string>
- using namespace std;
- class Employee
- {
- public:
- Employee (std::string name);
- string name;
- ~Employee();
- };
- #endif // EMPLOYEE
- //employee.cpp
- #include "employee.h"
- Employee::Employee (string set_name)
- {
- name = set_name;
- }
- Employee::~Employee()
- {
- }
- //manager.h
- #ifndef MANAGER
- #define MANAGER
- #include "employee.h"
- class Manager: public Employee
- {
- public:
- Manager (string set_name);
- float salary;
- ~Manager();
- };
- #endif // MANAGER
- //manager.cpp
- #include "manager.h"
- Manager::Manager (string set_name) : Employee (name)
- {
- salary = 52000.00;
- }
- Manager::~Manager()
- {
- }
- //part_time.h
- #ifndef PART_TIME
- #define PART_TIME
- #include <string>
- #include "dockhand.h"
- using namespace std;
- class Part_time: public Dockhand
- {
- public:
- Part_time (string set_name, bool set_forklift, int annual_leave, int sick_leave);
- float end_shift;
- int annual_leave;
- int sick_leave;
- ~Part_time();
- };
- #endif // PART_TIME
- //part_time.cpp
- #include "part_time.h"
- Part_time::Part_time (string set_name, bool set_forklift, int annual_leave, int sick_leave) : Dockhand (set_name, set_forklift)
- {
- end_shift = 8.00;
- payrate = 22.00;
- }
- Part_time::~Part_time()
- {
- }
- //finance.h
- #ifndef FINANCE
- #define FINANCE
- #include <vector>
- #include "freight.h"
- #include "employee.h"
- using namespace std;
- class Finance
- {
- public:
- Finance();
- ~Finance();
- };
- #endif // FINANCE
- //finance.cpp
- #include "finance.h"
- using namespace std;
- Finance::Finance()
- {
- }
- Finance::~Finance()
- {
- }
- //freight.h
- #ifndef PART_TIME
- #define PART_TIME
- #include <string>
- using namespace std;
- static const float MAX_SATCHEL_VOLUME = 0.20; // in m^3
- static const float MAX_CARTON_VOLUME = 0.50; // in m^3
- static const float SATCHEL_COST_PER_KILO = 2.00; // in dollars
- static const float CARTON_COST_PER_KILO = 1.00; // in dollars
- static const float PALLET_COST_PER_KILO = 0.50; // in dollars
- class Freight
- {
- public:
- enum FreightType
- {
- SATCHEL,
- CARTON,
- PALLET,
- };
- float cost()
- {
- return perKiloCost * weight;
- }
- private:
- Freight (string set_address, float set_length, float set_width, float set_height, float set_weight);
- string address;
- float length;
- float width;
- float height;
- float weight;
- FreightType type;
- float perKiloCost;
- ~Freight();
- };
- #endif // FREIGHT
- //freight.cpp
- #include "freight.h"
- Freight::Freight (string set_address, float set_length, float set_width, float set_height, float set_weight)
- {
- address = set_address;
- length = set_length;
- width = set_width;
- height = set_height;
- weight = set_weight;
- type;
- perKiloCost = 1.00;
- {
- float volume = length * width * height;
- if(volume > MAX_CARTON_VOLUME)
- {
- type = PALLET;
- perKiloCost = PALLET_COST_PER_KILO;
- }
- else if(volume > MAX_SATCHEL_VOLUME)
- {
- type = CARTON;
- perKiloCost = CARTON_COST_PER_KILO;
- }
- else
- {
- type = SATCHEL;
- perKiloCost = SATCHEL_COST_PER_KILO;
- }
- }
- }
- Freight::~Freight()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement