-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops.cpp
More file actions
96 lines (82 loc) · 1.64 KB
/
oops.cpp
File metadata and controls
96 lines (82 loc) · 1.64 KB
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
#include <iostream>
using namespace std;
class Student{
// properties
string name;
float cgpa;
public:
// methods
void getPercentage(){
cout << (cgpa * 10) << "% \n";
}
// Setters
void setName(string nameval){
name = nameval;
}
void setCgpa(float cgpaVal){
cgpa = cgpaVal;
}
// Getters
string getName(){
return name;
}
float getCgpa(){
return cgpa;
}
};
class User{
int id;
string username;
string password;
string bio;
void deactivate(){
cout << "deactivating account \n";
}
void editBio(string newBio){
bio = newBio;
}
};
class Car{
string name;
string colour;
public:
Car(){
cout << "constructor without parameter\n";
}
Car(string name, string colour){
cout << "constructor is called , object being created\n"
<< endl;
this->name = name;
this->colour = colour;
}
// Getter
string getName(){
return name;
}
string getColour(){
return colour;
}
void start(){
cout << "car has started" << endl;
}
void stop(){
cout << "car has stopped" << endl;
}
};
int main(){
Student s1;
s1.setName("APO");
s1.setCgpa(4.0);
// cout << s1.cgpa << endl;
s1.getPercentage();
cout << s1.getName() << endl;
cout << s1.getCgpa() << endl;
Car c1("maruti 800", "white");
cout << c1.getName() << endl;
cout << c1.getColour() << endl;
Car c0;
Car c2("fortuner", "white");
cout << c2.getName() << endl;
cout << c2.getColour() << endl;
return 0;
}