-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction_test.cpp
More file actions
41 lines (30 loc) · 1.6 KB
/
action_test.cpp
File metadata and controls
41 lines (30 loc) · 1.6 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
#include <iostream>
#include "Action.h"
#include "moveaction.h"
#include "Player.h"
#include "MoneyAction.h"
using namespace std;
int main()
{
Action act; // Create an Action via Default Constructor.
Action act2("Transfer"); // Create an Action via Value Constructor (nm = "Transfer")
act.print_name(); // Print the name of act.
act2.print_name(); // Print the name of act2.
cout << endl << " ---- END OF BASE CLASS TEST ---- " << endl << endl;
moveaction move("Test"); // Create a MoveAction object with base name "Transfer"
move.set_amount(50); // Set the amount of the MoveAction move.
move.print_name(); // Print the name of the MoveAction object move.
cout << "MOVE VALUE: " << move.get_amount() << endl; // Get the amount of the MoveAction move.
cout << endl << " ---- END OF DERIVED MOVEACTION CLASS TEST ---- " << endl << endl;
Player p2; // Create a 2nd player.
p2.give_money(500); // Give Player 2, 500 for money.
MoneyAction mAct("Player 1"); // Create a MoneyAction (Player 1).
mAct.setMoney(500); // Set the money for Player 1.
mAct.print_name(); // Print the name of Player 1.
cout << "PLAYER 1 MONEY: " << mAct.getMoney() << endl; // Get the money for Player 1.
mAct.pay_money(p2, 50); // Player 1 pays Player 2, 50.
cout << "PLAYER 1 MONEY: " << mAct.getMoney() << endl; // Get the money for Player 1.
cout << "PLAYER 2 MONEY: " << p2.getMoney() << endl; // Get the money for Player 2.
cout << endl << " ---- END OF DERIVED MONEYACTION CLASS TEST ---- " << endl << endl;
return 0;
}