forked from tamycova/30DaysHR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday4.cpp
More file actions
40 lines (38 loc) · 822 Bytes
/
day4.cpp
File metadata and controls
40 lines (38 loc) · 822 Bytes
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
class Person{
public:
int age ;
Person(int initial_Age);
void amIOld();
void yearPasses();
};
Person::Person(int initial_Age){
// Add some more code to run some checks on initial_Age
if (initial_Age < 0)
{
cout<<"This person is not valid, setting age to 0."<<endl;
Person::age = 0;
}
else
{
Person::age = initial_Age;
}
}
void Person::amIOld(){
// Do some computations in here and print out the correct statement to the console
if(Person::age <13)
{
cout<<"You are young."<<endl;
}
else if(Person::age <18)
{
cout<<"You are a teenager."<<endl;
}
else
{
cout<<"You are old."<<endl;
}
}
void Person::yearPasses(){
// Increment the age of the person in here
Person::age = Person::age + 1;
}