-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMidterm.cpp
103 lines (72 loc) · 2.46 KB
/
Midterm.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
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
/*
@file midterm.cpp
@author Sean Resor
@date 4/12/21
*/
// Header files to include
#include <stdio.h>
#include <iostream>
#include <string>
#include <ctime>
#include "BadDude.h"
// Using standard namespace
using namespace std;
int main()
{
// Sets the seed of the random number generator
srand(time(0));
// Instantiates a Person object
person* Sally = new person("Sally", "Smith");
// Prints the Person object's name
Sally->Show();
// Instantiates a Person object
person* Steve = new person();
// Uses overloaded assignment operator to set new Person object equal to old Person object
Steve = Sally;
cout << "Demonstrating successful assignment...\n";
// Prints the Person object's name
Steve->Show();
// Calls destructor for Person objects
delete Sally;
// Instantiates a Gunslinger object
gunslinger* Wyatt = new gunslinger("Wyatt", "Earp", 1.5, 10);
// Prints the Gunslinger object's details
Wyatt->Show();
// Prints the Gunslinger object's draw speed
cout << "Their draw speed is: " << Wyatt->Draw() << endl << endl;
cout << "Demonstrating successful assignment...\n";
// The next three lines demonstrate the functioning assignment operator
gunslinger* Doc = new gunslinger();
Doc = Wyatt;
Doc->Show();
// Calls destructor for Gunslinger objects
delete Wyatt;
// Instantiates a PokerPlayer object
pokerPlayer* Victoria = new pokerPlayer("Victoria", "Coren");
// Prints the PokerPlayer object's details
Victoria->Show();
// Draws a card for the PokerPlayer object
cout << "The card drawn is card number: " << Victoria->Draw() << endl << endl;
cout << "Demonstrating successful assignment...\n";
// The next three lines demonstrate the functioning assignment operator
pokerPlayer* Daniel = new pokerPlayer();
Daniel = Victoria;
Daniel->Show();
// Calls destructor for PokerPlayer objects
delete Victoria;
// Instantiates a BadDude object
badDude* Michael = new badDude("Michael", "Scott", 3.5, 1);
// Prints the BadDude object's details
Michael->Show();
// Prints out the BadDude object's draw speed and draws a card for them
cout << "Their draw speed is: " << Michael->Gdraw() << endl;
cout << "The card they draw is card number: " << Michael->Cdraw() << endl << endl;
cout << "Demonstrating successful assignment...\n";
// The next three lines demonstrate the functioning assignment operator
badDude* Dwight = new badDude();
Dwight = Michael;
Dwight->Show();
// Calls destructor for BadDude objects
delete Michael;
return 0;
}