-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHoldable.cpp
70 lines (62 loc) · 1.99 KB
/
Holdable.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
/***********************************************************
Class Name: Holdable
Author: Howard Chen
Last Modified: 3-18-2017
Description: This class defines the Holdable objects that have weight,
that the Player is permitted to hold.
***********************************************************/
#include "Holdable.hpp"
#include <iostream>
/**************************************
Description: Default constructs a Holdable object.
Arguments: None.
Precondition: None.
Postcondition: weight = 0,
rest are values from default construction of Object.
**************************************/
Holdable::Holdable() :
Object() {
weight = 5;
name = "default holdable";
}
/**************************************
Description: Custom constructs a Holdable object.
Arguments: [1] name, [2] description, [3] key, [4] weight
Precondition: None.
Postcondition: name = n, description = d, key = k, weight = w
**************************************/
Holdable::Holdable(std::string n, std::string d, std::string k, double w) :
Object(n, d, k) {
weight = w;
}
//virtual destructor
Holdable::~Holdable(){}
/**************************************
Description: Returns weight of Holdable object.
Arguments: None.
Precondition: None.
Postcondition: Returns weight.
**************************************/
double Holdable::getWeight(){
return weight;
}
/**************************************
Description: Sets weight of Holdable object.
Arguments: double representing weight.
Precondition: None.
Postcondition: weight = w;
**************************************/
void Holdable::setWeight(double w) {
weight = w;
}
/**************************************
Description: Debugging function. Logs member variables of
Holdable object to console.
Arguments: None.
Precondition: None.
Postcondition: Prints member variables to console.
**************************************/
void Holdable::log() {
Object::log();
std::cout << "Weight: " << weight << std::endl;
}