-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
63 lines (52 loc) · 1.23 KB
/
main.cpp
File metadata and controls
63 lines (52 loc) · 1.23 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
//============================================================================
// Name : CMPE126-classActivity.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <string>
using namespace std;
#include "Animal.h"
// Main function to test the classes
int main() {
// Create an instance of Animal
Animal genericAnimal("Generic", 5);
genericAnimal.makeSound();
// Create an instance of Dog
Dog dog("Buddy", 10, "Golden Retriever");
dog.makeSound();
cout<< dog << endl;
// Create an instance of Cat
Cat cat("Whiskers", 2, "Black");
cat.makeSound();
cout<< cat << endl;
Cat Two;
cin >> Two;
cout<<Two<<endl;
//who is older
if (Two.isOlder(dog)){
cout<< Two.getName()<< " is older."<< endl;
}
else{
cout<< dog.getName()<< " is older."<< endl;
}
//OUTPUT
/*
* BAAAAA SOUND
Bark
Dog Name:Buddy, Age: 10, Breed: Golden Retriever
Buddy is Old
Meow
Cat Name: Whiskers, Age: 2, Color: Black
Whiskers is Young
Enter name: Sara
Enter age: 7
Enter color: Orange
Cat Name: Sara, Age: 7, Color: Orange
Sara is Old
Buddy is older.
*/
return 0;
}