I need Help code of classes and object

May 8, 2012 at 4:00pm
Write a program in C++ using Object Oriented Concept (Classes and Objects) for the following system. For this project, you need to write C++ console application and no database required.
System requirements
MEDIU wants to have a system for its training unit. The system will be refer as Training Management System. Training unit is providing training courses to everyone. For example, Basic Speaking in Arabic, Basic Speaking in English, Programming in C++ and etc. For this project, basically you need to do the following

1.The system can offer training courses
2. Any user can register for training courses.
Training officer will use this system to view, add, update and delete training item. Training item is basically offered training courses which will be open to any user to register.
User can register for one or more trainings. User can't register the same training courses item at the same time. After user has selected one or more training courses, the system willl display the list of selected training courses and total price that the user need to pay.
Special requirements
If Mediu student, you will have 20% discount of the training price.
Properties required for training item and user.
A. Training item
1. Code
2. Title
3. Trainer's name
4. Duration of training (in hours)
5. Start date of training
6. End date of training
7. Price of training
B. User
1. Name
2. Email
3. Phone number
4. Is a mediu student or not?
May 8, 2012 at 4:01pm
can anybody help me in this project ??
May 8, 2012 at 4:39pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class item
{
      public:
      int code; // or string, I don't know what the code is
      string title;
      string trainer;
      int duration;
      struct date
      {
             int day, month, year;
             date() :day(), month(), year(){}
             date (int a, int b, int c): day(a), month(b), year(c){}
             };
      date start, end;
      int price;
      item(): code(), title(), trainer(), duration(), start(), end(), price() {}
      item(int c, string tit, string train, int dur, int dstart, int mstart, int ystart, int dend, int mend, int yend, int pr):
      code(c), title(tit), trainer(train), duration(dur), start(dstart, mstart,ystart), end(dend, mend, yend), price(pr) {}
      };
class user
{
      public:
      string name;
      string email;
      string phone;
      bool is_mediu;
      user(): name(), email(), phone(), is_mediu(){}
      user(string n, string mail, string num, bool mediu): name(n), email(mail), phone(num), is_mediu(mediu){}
      }; 

Is this enough?
May 9, 2012 at 6:57am
please , me too I need to help in this project ????
can you complete please
please please please, I need necessary
May 9, 2012 at 12:24pm
man, people theese days arebecoming more and more dependant.
May 9, 2012 at 1:07pm
Can we? Sure, we "can", but we won't. Why? Because you both need to stop being lazy and at least write most of the code yourself. Giving you "help" does not mean giving you the entire answer, so you're going to have to ask more specific questions about what you need help with.
May 9, 2012 at 1:19pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class item
{
    public:
    int code;
    string title;
    string trainer;
    int duration;
	struct date
    {
        int day, month, year;
        date() :day(), month(), year(){}
        date (int a, int b, int c): day(a), month(b), year(c){}
        inline bool operator==(const date& x)
        {
			return day==x.day && month==x.month && year==x.year;
			}
        };
    date start, end;
    double price;
    item(): code(), title(), trainer(), duration(), start(), end(), price() {}
    item(int c, string tit, string train,
	int dur, int dstart, int mstart, int ystart,
	int dend, int mend, int yend, double pr):
    code(c), title(tit), trainer(train), duration(dur),
	start(dstart, mstart,ystart), end(dend, mend, yend), price(pr) {}
	inline bool operator==(const item& x)
	{
		return code==x.code && title==x.title && trainer==x.trainer &&
		duration==x.duration && start==x.start && end==x.end && price==x.price;
		}
	};
	
istream& operator>>(istream& fin, item::date a)
{
	return fin>>a.day>>a.month>>a.year;
	}

ostream& operator<<(ostream& stm, item::date a)
{
	return stm<<a.day<<"."<<a.month<<"."<<a.year<<".";
	}
	
istream& operator>>(istream& fin, item& a)
{
	return fin>>a.code>>a.title>>a.trainer>>a.duration>>a.start>>a.end>>a.price;
	}

ostream& operator<<(ostream& stm, item& a)
{
	return stm<<a.code<<"\t"<<a.title<<"\t"<<a.trainer<<"\t"<<
	a.duration<<"\t"<<a.start<<"\t"<<a.end<<"\t"<<a.price;
	}

ostream& operator<<(ostream& stm, const vector<item>& vec)
{
	for(auto a:vec)
	{
		stm<<a<<endl; 
		}
	return stm;
}

class user
{
    public:
    string name;
    string email;
    string phone;
    bool is_mediu;
    vector<item> items;
    double cost;
    user(): name(), email(), phone(), is_mediu(), items(), cost(){}
    user(string n, string mail, string num, bool mediu):
		name(n), email(mail), phone(num), is_mediu(mediu), items(), cost(){}
    void register_to(item it)
    {
		if (find(items.begin(), items.end(), it)!=items.end())
		items.push_back(it);
		if (is_mediu) cost+=it.price/5.0*4.0;
		else cost+=it.price;
		}
	};

istream& operator>>(istream& fin, user& a)
{
	a=user();
	return fin>>a.name>>a.email>>a.phone>>a.is_mediu;
	}

ostream& operator<<(ostream& stm, user& a)
{
	return stm<<a.name<<"\t"<<a.items<<"\t"<<a.cost;
	}

int main()
{
	ifstream fin("sample.txt");
	int n;
	vector<user> users;
	user temp1;
	item temp2;
	while (!fin.eof())
	{
		fin>>temp1>>n;
		for (int i=0; i<n; i++)
		{
			fin>>temp2;
			temp1.register_to(temp2);
			}
		}
	cout<<"name\tcode\ttitle\ttrainer\tduration\tstart\tend\tprice\ttotal cost";
	for(auto a:users)
	{
		cout<<a<<endl;
		}
}

there, it only has a litle bug, and you find out what it is, and fix it. I've helped more than enough
May 9, 2012 at 5:59pm
Kazekan : am agree with what u said, i tried but i can not complete the project because i did not attend this class so i just want some example and don't worry i never be lazy
----------
thank you so much Viliml :)
Topic archived. No new replies allowed.