aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Blashchishina <[email protected]>2024-02-22 17:20:05 -0800
committerYana Blashchishina <[email protected]>2024-02-22 17:20:05 -0800
commitf462ee4b7147e8d3d06feb70b95def57aa592997 (patch)
tree75a8de91edf3785b01010d1c9eaa27cf0823889b
parentomg i forgot to commit at all (diff)
downloadin-class-exercise-13-yanablash-f462ee4b7147e8d3d06feb70b95def57aa592997.tar.xz
in-class-exercise-13-yanablash-f462ee4b7147e8d3d06feb70b95def57aa592997.zip
completed but with an error that I cant figure outHEADmain
-rw-r--r--InClassExercise13/InClassExercise13/Contacts.cpp40
-rw-r--r--InClassExercise13/InClassExercise13/Contacts.h29
-rw-r--r--InClassExercise13/InClassExercise13/main.cpp18
3 files changed, 28 insertions, 59 deletions
diff --git a/InClassExercise13/InClassExercise13/Contacts.cpp b/InClassExercise13/InClassExercise13/Contacts.cpp
index 055dccf..7256636 100644
--- a/InClassExercise13/InClassExercise13/Contacts.cpp
+++ b/InClassExercise13/InClassExercise13/Contacts.cpp
@@ -1,26 +1,25 @@
#include "Contacts.h"
#include <iostream>
+
+
Contact::Contact() { }
-Contact::Contact(const char* name, const short age){
- _name = name;
- _age = age;
+Contact::Contact(const char* firstName, const char* lastName, const char* streetAddress, const char* city, const char* state, int zip, const char* email){
+ _firstName = firstName;
+ _lastName = lastName;
+ _streetAddress = streetAddress;
+ _city = city;
+ _state = state;
+ _zip = zip;
+ _email = email;
}
Contact::~Contact() { }
-void Contact::SetAge(short age) {
- _age = age;
-}
-short Contact::GetAge() {
- return _age;
-}
void Contact::Print() {
- std::cout << "Name: " << _name << std::endl;
- std::cout << "Age: " << _age << std::endl;
std::cout << "First Name: " << _firstName << std::endl;
std::cout << "Last Name: " << _lastName << std::endl;
std::cout << "Street Address: " << _streetAddress << std::endl;
@@ -30,14 +29,6 @@ void Contact::Print() {
std::cout << "Email: " << _email << std::endl;
}
-const char* Contact::GetName() {
- return _name;
-}
-
-void Contact::SetName(const char* name) {
- _name = name;
-}
-
@@ -61,7 +52,7 @@ const char* Contact::GetLastName() {
const char* Contact::GetStreetAddress() {
- return _streetAdress;
+ return _streetAddress;
}
void Contact::SetStreetAddress(const char* streetAddress) {
@@ -82,12 +73,12 @@ void Contact::SetState(const char* state) {
_state = state;
}
-const int Contact::GetZip() {
+int Contact::GetZip() {
return _zip;
}
-void Contact::SetZip(const int zip) {
- return zip;
+void Contact::SetZip(int zip) {
+ _zip = zip;
}
const char* Contact::GetEmail() {
@@ -96,4 +87,5 @@ const char* Contact::GetEmail() {
void Contact::SetEmail(const char* email) {
_email = email;
-} \ No newline at end of file
+}
+
diff --git a/InClassExercise13/InClassExercise13/Contacts.h b/InClassExercise13/InClassExercise13/Contacts.h
index e08f3eb..7a28412 100644
--- a/InClassExercise13/InClassExercise13/Contacts.h
+++ b/InClassExercise13/InClassExercise13/Contacts.h
@@ -4,23 +4,15 @@
class Contact {
public:
Contact();
- Contact(const char* name, const short age);
+ Contact(const char* firstName,const char* lastName, const char* streetAddress, const char* city, const char* state, int zip, const char* email);
~Contact();
- short GetAge();
- void SetAge(short age);
-
- const char* GetName();
-
- void SetName(const char* name);
void Print();
-
-
const char* GetFirstName();
void SetFirstName(const char* firstName);
@@ -36,7 +28,7 @@ public:
const char* GetState();
void SetState(const char* state);
- const int GetZip();
+ int GetZip();
void SetZip(int zip);
@@ -44,19 +36,18 @@ public:
const char* GetEmail();
void SetEmail(const char* email);
- void Print();
+
private:
- const char* _name{ };
- short _age{ 0 };
+
const char* _firstName{ };
- char* _lastName{ };
- char* _streetAddress{ };
- char* _city{ };
- char* _state{ };
- int zip;
- char* _email{ };
+ const char* _lastName{ };
+ const char* _streetAddress{ };
+ const char* _city{ };
+ const char* _state{ };
+ int _zip{ 0 };
+ const char* _email{ };
};
diff --git a/InClassExercise13/InClassExercise13/main.cpp b/InClassExercise13/InClassExercise13/main.cpp
index fc9b794..2ca557b 100644
--- a/InClassExercise13/InClassExercise13/main.cpp
+++ b/InClassExercise13/InClassExercise13/main.cpp
@@ -10,23 +10,9 @@ int main() {
Contact newContact;
- std::cout<<newContact.GetAge();
+ std::cout<<newContact.GetFirstName();
- newContact.SetAge(42);
- newContact.SetName("Joe Biden");
- newContact.Print();
-
- newContact.SetAge(50);
- newContact.SetName("Obama");
-
-
- newContact.Print();
-
- Contact anotherContact("We did it joe", 76);
-
- anotherContact.Print();
-
newContact.GetFirstName();
newContact.SetFirstName("Yana");
@@ -44,7 +30,7 @@ int main() {
newContact.SetState("Not California");
newContact.GetZip();
- newContact.SetZip("97089");
+ newContact.SetZip(97089);
newContact.GetEmail();