This is an assignment due in 6 days. The point is to make an address book to store the information of a contact. The information stored will be:
1.first and last name
2.relation to you ( a character{F,B or R)
3.address
4.phone number
5.birth date
The professor wants us to create an ordered linked list. I don't know how to start. I have created a composed class (extPersonType) that contains all the information needed to create a contact (the 5 above).
I was thinking about declaring extPersonType in the node as "info" or data contained in the node. So the input required of extPersonType goes to the info or data variable in the node.
In my program I haven't really declared a listType. I want it to be named addressBookType and make that the linked list. The addressBookType ordered linked list has to be able to:
1.)load data from file
2.)sort by last name ( I will be sorting as I build (insert or delete) data since it's a sorted linked list.)
3.)search by last name
4.)print by relation {F, B, R} (family, business associate, friend) (stored in relation from extPersonType)
5.)Print By month of birthDate
6.)Print all the people with the same last name
7.)add or delete contacts
8.)save data to file
Any suggestions on how I can create code for a sorted linked list named addressBookType using extPersonType as data for the nodes? I want it to be in separate files (.h & .cpp) I just am not quite sure on how to do this since I haven't dealt with linked lists before this assignment.
NOTE: I have to make a linkedListType first and then make sortedLinkedListType acccording to the professor. {I want to name it addressBookType}
I have provided code of my classes. Again... extPersonType is the class I want to implement in the node as data. Any suggestions/critics/advice are greatly appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#pragma once
#include <string>
#include <iostream>
using namespace std;
class personType
{
public:
personType(string = "", string = "");
string getFirstName() const;
string getLastName() const;
private:
string firstName;
string lastName;
};
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include "personType.h"
personType::personType(string tFirst, string tLast)
{
if (tFirst == "" && tLast == "")
{
cout << "invalid first and last name." << endl;
}
else
{
firstName = tFirst;
lastName = tLast;
}
}
string personType::getFirstName() const
{
return firstName;
}
string personType::getLastName() const
{
return lastName;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#pragma once
#include "iostream"
#include "string"
using namespace std;
class dateType
{
public:
dateType(int month = 1, int day = 1, int year = 1);
int getMonth() const;
int getDay() const;
int getYear() const;
private:
int dDay;
int dMonth;
int dYear;
};
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include "dateType.h"
dateType::dateType(int month, int day, int year)
{
//sets and validates date
}
int dateType::getMonth() const
{
return dMonth;
}
int dateType::getDay() const
{
return dDay;
}
int dateType::getYear() const
{
return dYear;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#pragma once
#include <string>
#include "iostream"
using namespace std;
class addressType
{
public:
addressType(string = "", string = "", string = "", string = "");
string getStreet() const;
string getCity() const;
string getState() const;
string getZip() const;
private:
string streetAddress;
string cityAddress;
string stateAddress;
string zipAddress;
};
|
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
|
#include "addressType.h"
addressType::addressType(string street, string city, string state, string zip)
{
if (street == "" && city == "" && state == "" && zip == "")
{
//exception, address is empty.
}
else
{
streetAddress = street;
cityAddress = city;
stateAddress = state;
zipAddress = zip;
}
}
string addressType::getStreet() const
{
return streetAddress;
}
string addressType::getCity() const
{
return cityAddress;
}
string addressType::getState() const
{
return stateAddress;
}
string addressType::getZip() const
{
return zipAddress;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#pragma once
#include "string"
#include "iostream"
using namespace std;
class phoneNumber
{
public:
phoneNumber(string = "");
string getPhone() const;
private:
string formatedPhoneNum;
};
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include "phoneNumber.h"
#include "string"
#include "iostream"
using namespace std;
phoneNumber::phoneNumber(string prototypePhoneNum)
{
//sets and validates phone number
}
string phoneNumber::getPhone() const
{
return formatedPhoneNum;
}
|
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
|
#pragma once
#include "personType.h"
#include "dateType.h"
#include "AddressType.h"
#include "phoneNumber.h"
#include "string"
#include "iostream"
using namespace std;
class extPersonType
{
public:
extPersonType(string = "", string = "", string = "", int = 1, int = 1, int = 1900, string = "", string = "", string = "", string = "", string = "");
string getLastName() const;
string getRelation() const;
int getMonth() const;
void print() const;
private:
personType firstLastName;
string relation;
dateType dateOfBirth;
addressType contactAddress;
phoneNumber contactNumber;
};
|
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
|
#include "extPersonType.h"
extPersonType::extPersonType(string first, string last, string relat,
int month, int day, int year, string street, string city,
string state, string zip, string phone)
:firstLastName(first, last), dateOfBirth(month, day, year),
contactAddress(street, city, state, zip), contactNumber(phone)
{
if (relat == "B" || relat == "F" || relat == "R")
{
relation = relat;
}
else
{
cout << "invalid relation" << endl; // exception, invalid relation.
}
}
string extPersonType::getLastName() const
{
return firstLastName.getLastName();
}
string extPersonType::getRelation() const
{
return relation;
}
int extPersonType::getMonth() const
{
return dateOfBirth.getMonth();
}
void extPersonType::print() const
{
//print function
}
|
~thank you for your time.