-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPet.cpp
More file actions
72 lines (60 loc) · 1.62 KB
/
Copy pathPet.cpp
File metadata and controls
72 lines (60 loc) · 1.62 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
//************************************************************************
// Author: Rolando Carreon
// Date: may 14 2025
// Language: C++
// Assignment: Demo Pet Class Project.cpp
// Description: Implementation file that defines the methods (functions)
// i.e. logic behind how the methods work
//************************************************************************
#include <iostream>
#include "Pet.hpp" // access the class pet // adds prototypes
using namespace std; // for cin and cout
// getters
string Pet::getName() const // get the name of the pet
{
return name; // return the name
}
string Pet::getPetType() const // get the type of pet
{
return petType;
}
string Pet::getSound() const // get the sound the pet makes
{
return sound;
}
// setters
// void doesnt return anything just sets the value to be called later
void Pet::setName(string pName) // set the name of the pet
{
name = pName; // set the name
}
void Pet::setPetType(string pType) // set the type of pet
{
petType = pType;
}
void Pet::setSound(string pSound) // set the sound the pet makes
{
sound = pSound;
}
// print function
void Pet::print()
{
// set the pet details
cout << "Name: " << name << endl
<< "Type: " << petType << endl
<< "Sound: " << sound << endl;
}
// default constructor // if no parameters are passed
Pet::Pet()
{
name = "Unknown Pet Name";
petType = "Unknown Pet Type";
sound = "Unkown Pet Sound";
}
// constructor with all parameters // user knows all values
Pet::Pet(string pName, string pType, string pSound)
{
name = pName;
petType = pType;
sound = pSound;
}