-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBird.h
More file actions
79 lines (65 loc) · 1.71 KB
/
Bird.h
File metadata and controls
79 lines (65 loc) · 1.71 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Bird.h
* Author: Chris Frey
*
* Created on February 11, 2018, 8:22 PM
*/
#ifndef BIRD_H
#define BIRD_H
#include "Pet.h"
#include <string>
#include <iostream>
#include <iomanip>
#include "visitor.h"
class Bird : public Pet{
protected:
bool m_nocturn = false;
public:
// Default Constructor
Bird() : Pet(){}
// Constructor
Bird(std::string name, std::string type, double price, unsigned int weight,
bool nocturn)
: Pet(name,type,price,weight,"Bird"){
m_nocturn = nocturn;
}
// Destructor
virtual ~Bird(){}
// Copy constructor
Bird(const Bird& brd)
: Pet(brd){
if (this != &brd){
m_nocturn = brd.m_nocturn;
}
}
// Assignment operator
Bird& operator=(const Bird& brd){
if (this != &brd){
this->Pet::operator=(brd);
m_nocturn = brd.m_nocturn;
}
return *this;
}
bool GetNocturnality() const {
return m_nocturn;
}
void SetNocturnality(bool input){
m_nocturn = input;
}
virtual void print() const {
std::cout << std::fixed << std::setprecision(2);
std::cout << std::boolalpha;
std::cout << "Name: " << m_name << " ";
std::cout << "Type: " << m_type << " ";
std::cout << "Weight: " << m_weight << " ";
std::cout << "Price: " << m_price << " ";
// Special trait
std::cout << "Nocturnal: " << m_nocturn << " " << std::endl;
}
};
#endif /* BIRD_H */