-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusama_yazdani_20p-0598_#Q2_section_D.cpp
72 lines (58 loc) · 1.4 KB
/
usama_yazdani_20p-0598_#Q2_section_D.cpp
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
#include<iostream>
using namespace std;
class Wheels
{
private: //data members of class wheel
string single_variable;
public:
void set_wheel_state(string s) //input from user and assigning
{
single_variable=s;
}
string get_wheel_state() //returning state
{
return single_variable;
}
};
class Car
{
private:
Wheels w1[4]; //class type array
string w;
public:
void set_car_to_moving() //set state to tuning
{
cout<<"Car State :"<<endl;
for(int i=0; i<4; i++)
{
w1[i].set_wheel_state("Turning");
}
}
void set_car_to_stopped()
{
cout<<"Car State :"<<endl;
for(int i=0; i<4; i++)
{
w1[i].set_wheel_state("Stopped");
}
}
void print_car_wheel_state()
{
for(int i=0; i<4; i++)
{
//calling function in wheel class and cout the current state
cout<<"Wheel "<<i<<" is "<<w1[i].get_wheel_state()<<endl;
}
}
};
int main()
{
Wheels W1;
W1.set_wheel_state("Turning");
cout<<W1.get_wheel_state()<<endl;
Car c1;
c1.set_car_to_moving();
c1.print_car_wheel_state();
c1.set_car_to_stopped();
c1.print_car_wheel_state();
}