Objectives The objective of this assignment is for you to gain practice with the following: Design and implement a data collection List as an abstract data type (ADT) class that satisfies a set of...


Objectives


The objective of this assignment is for you to gain practice with the following:



  • Design and implement a data collection List as an abstract data type (ADT) class that satisfies a set of given requirements.

  • Apply the four steps of the software development process while creating an object-oriented (OO) solution to a problem.




Step 1 - Problem Statement and Requirements


In this assignment, you are asked to develop a fitness studio registration system. The goal of this system is to manage the records of all the members registering to the fitness studio.


The fitness studio keeps the following information about all its members: the member's name (first and last name), cell phone number, email address and credit card number.


The fitness studio registration system must allow the fitness studio front desk attendant to



  • create a new record for a potential member into the system

  • remove the record of a member (that is leaving the fitness studio) from the system

  • search for the record of an existing member

  • modify a member's record (for example, changing the number of a member's expired credit card with the number of a new credit card)

  • print all the current members, currently attending the fitness studio, in descending order of cell phone number.



About the "print" option from the above menu,hereis what its output should look like (i.e., the format).




Step 2 - Design


In this assignment, the design step, in which you establish the classes you shall need in your software solution, has been done for you. Indeed, you shall need two C++ classes and a file containing themainfunction:



  • The class that models each member of the fitness studio: Member class.

  • The class that manages all the member objects: List class.

  • And the fitness studio registration system file that contains themainfunction and other functions: FitStudioReg.cpp.


The attributes and the list of operations of these classes have also been designed for you.


The part of the design you need to do in this assignment is designing the algorithm for some of these classes' operations and the functions of the fitness studio registration system file.




Step 3 - Implementation



  • DownloadMember.handMember.cpp. As you read through Member.cpp, you will notice that it is incomplete. Use the documentation and code they already contain to guide your implementation/completion of Member.cpp. Note that you cannot remove/modify the code that is already in both files.

  • DownloadList.hand read its content. Complete its implementation. This signifies: create List.cpp. In doing so, you cannot remove/modify the code that is already in List.h. Also, don't forget to add to the class invariant of List class (see its header comment block).

  • The print method of the List class must have a time efficiency of O(n) where n is the number of elements in the List.Note:What does this imply for the rest of the methods of List?

  • DownloadFitStudioReg.cppand read its content. Complete its implementation. In doing so, you can add more functions to this file, but you cannot remove/modify the code that is already there.

  • Each of your files must contain a comment header block composed of filename, class description, class invariant (if any), author, date of creation.

  • All your class methods (public and private) must have appropriate documentation: a description, a precondition (if any) and a postcondition (if any). Most of this documentation has already been provided for you. Make sure you understand its purpose.Note:The same documentation must appear in the class header file (.h) and in the class implementation file (.cpp) of each of your classes.

  • Your solution must not make use of already existing container classes such as the STL vector class, etc... You cannot use STL in this assignment.

  • Finally, make sure your code satisfies theGood Programming Styledescribed on the Good Programming Style web page of our course web site.



Why can you not remove/mofidy the code already found in these files (i.e., the public interface given in Member.h and List.h)?


Because, when we mark Assignment 1, we will test your submitted classes with a test driver program (client code) that will be implemented using the public interface of the Member and the List classes, i.e., the public part of Member.h and List.h. If you change the provided public interfaces (for example, if you change the type of a parameter from "float" to "int"), the test driver program used for marking your assignments will no longer compile with your submitted Member and the List classes, and marks will be deducted.




Step 4 - Compilation and Testing


You must use thismakefileto compile (on ourtarget machine) the files you create in this assignment.


This makefile must not be modified. If it does not work for you, make sure you are using it on ourtarget machine. If it still does not work for you, please, see the instructor.


Make sure you test each of your classes separetly by creating a test driver for your Member class and for your List class.


*

* Member.h

*


* Class Description: Models a Fitness Studio Registration System.

* Class Invariant: Each member has a unique cell phone number.

* This cell phone number must have 12 digits.

* This cell phone number must have the following format: XXX-XXX-XXXX.

* This cell phone number cannot be modified.


*

* Author: AL

* Last modified: Sept. 2022

*/


#ifndef MEMBER_H
#define MEMBER_H


#include


using namespace std;


class Member {


/* You cannot change this file (i.e., the definition of this class). */


private:



constexpr static const int SIZE_OF_PHONE_NUMBER = 12;



string name;


string phone;

string email;

string creditCard;



// Description: Sets the member's cell phone number - Private method

// Reflection: Why is this method not part of the public interface?

void setPhone(const string aPhone);


public:



// Default Constructor

// Description: Create a member with a cell phone number of "000-000-0000".


// Postcondition: All data members set to an empty string,


// except the cell phone number which is set to "000-000-0000".

Member();



// Parameterized Constructor

// Description: Create a member with the given cell phone number.

// Postcondition: If aPhone does not have 12 digits, then aPhone is set to "000-000-0000".

// All other data members set to an empty string.

Member(string aPhone);



// Parameterized Constructor

// Description: Create a member with the given name, cell phone number, email and credit card number.

// Postcondition: If aPhone does not have 12 digits, then aPhone is set to "000-000-0000".

Member(string aName, string aPhone, string anEmail, string aCreditCard);





// Getters and setters

// Description: Returns member's name.

string getName() const;



// Description: Returns member's phone.

string getPhone() const;



// Description: Returns member's email.

string getEmail() const;



// Description: Returns member's credit card.

string getCreditCard() const;



// Description: Sets the member's name.

void setName(const string aName);



// Description: Sets the member's email.

void setEmail(const string anEmail);



// Description: Sets the member's credit card number.

void setCreditCard(const string aCreditCard);





// Overloaded Operators

// Description: Comparison operator. Compares "this" Member object with "rhs" Member object.

// Returns true if both Member objects have the same cell phone number.

bool operator == (const Member & rhs);



// Description: Greater than operator. Compares "this" Member object with "rhs" Member object.

// Returns true if the cell phone number of "this" Member object is > the


// cell phone number of "rhs" Member object.

bool operator > (const Member & rhs);



// Description: Less than operator. Compares "this" Member object with "rhs" Member object.

// Returns true if the cell phone number of "this" Member object is <>


// cell phone number of "rhs" Member object.

bool operator < (const="" member="" &="">



// For testing purposes!

// Description: Prints the content of "this".

// Example: Louis Pace, 604-853-1423, [email protected], 1234 5678 9098 7654


friend ostream & operator<(ostream &="" os,="" const="" member="" &="">


}; // end of Member.h
#endif

/*

* Member.cpp

*


* Class Description: Models a Fitness Studio Registration System.

* Class Invariant: Each member has a unique cell phone number.

* This cell phone number must have 12 digits.

* This cell phone number must have the following format: XXX-XXX-XXXX.

* This cell phone number cannot be modified.


*

* Author: AL

* Last modified: Sept. 2022

*/




#include
#include
#include "Member.h"






// Overloaded Operators
// Description: Comparison operator. Compares "this" Member object with "rhs" Member object.
// Returns true if both Member objects have the same cell phone number.
bool Member::operator == (const Member & rhs) {



return this->phone == rhs.getPhone();
}


// Description: Greater than operator. Compares "this" Member object with "rhs" Member object.
// Returns true if the cell phone number of "this" Member object is > the

// cell phone number of "rhs" Member object.
bool Member::operator > (const Member & rhs) {



return this->phone > rhs.getPhone();
}



// Description: Less than operator. Compares "this" Member object with "rhs" Member object.
// Returns true if the cell phone number of "this" Member object is <>

// cell phone number of "rhs" Member object.
bool Member::operator < (const="" member="" &="" rhs)="">



return this->phone <>
}



// For testing purposes!
// Description: Prints the content of "this".
// Example: Louis Pace, 604-853-1423, [email protected], 1234 5678 9098 7654

ostream & operator<(ostream &="" os,="" const="" member="" &="" p)="">



os < p.name="">< ",="" "="">< p.phone="">< ",="" "="">< p.email="">< ",="" "="">< p.creditcard=""><>




return os;
}



// end of Member.cpp

/*

* List.h

*


* Class Description: List data collection ADT.

* Class Invariant: Data collection with the following characteristics:

* - Each element is unique (no duplicates).

* - ***There is another class invariant: Add it here!***

*

* Author: AL

* Last modified: Sept. 2022

*/


#ifndef LIST_H
#define LIST_H


#include
#include "Member.h"


class List {


/* You cannot change this file (i.e., the definition of this class). */


private:



constexpr static const int CAPACITY = 5;


Member * elements = NULL; // Data structure of elements

unsigned int elementCount = 0; // Number of elements in the data structure



void clear();


public:



// Default constructor

List();



// Destructor

// Description: Destruct a List object, releasing heap-allocated memory.

~List();



// Description: Returns the total number of elements currently stored in List.

unsigned int getElementCount() const;



// Description: Insert an element.

// Precondition: newElement must not already be in data collection.


// Postcondition: newElement inserted in its proper place in List

// and elementCount has been incremented.


bool insert( Member& newElement );



// Description: Remove an element.


// Postcondition: toBeRemoved is removed (leaving no gap in the data structure of List)

// and elementCount has been decremented.


bool remove( Member& toBeRemoved );



// Description: Remove all elements.

// Postcondition: List is back to the state it was right after being constructed.

void removeAll();



// Description: Search for target element.

// Returns a pointer to the element if found,

// otherwise, returns NULL.

Member* search( Member& target );



// Description: Prints all elements stored in List by descending order of search key.

// Time Efficiency: O(n)

void printList();


}; // end List.h
#endif

/*

* FitStudioReg.cpp - Assignment 1

*

* Class Description: Fitness Studio Registration System

*

* Author: AL

* Last modified: Sept. 2022

*/


#include
#include
#include
#include "Member.h"
#include "List.h"


using std::cout;


int main() {



// Variables declaration

List* Members = new List();

bool done = false;

char input = 0;



// Keep going until the user exits

while (not done) {

// Print menu to stdout

cout < endl="">< "----welcome="" to="" the="" fitness="" studio="" registration="" system!"=""><>

cout < endl="">< "enter="" ..."="">< endl=""><>

cout < "a="" -=""> to add a new member" <>

cout < "r="" -=""> to remove a member" <>

cout < "s="" -=""> to search for a member" <>

cout < "m="" -=""> to modify the record of a member" <>

cout < "p="" -=""> to print all members" <>

cout < "x="" -=""> to exit\n" <>



cout < "your="" choice:="">

cin >> input;

cout <>

input = tolower(input);

switch(input) {

case 'a': add(Members); break;

case 'r': remove(Members); break;

case 's': search(Members); break;

case 'm': modify(Members); break;

case 'p': print(Members); break;

case 'x': cout < "\n----bye!\n"="">< endl;="" done="true;">

default: cout < "not="" sure="" what="" you="" mean!="" please,="" try="" again!"=""><>

}

}

return 0;
}
Sep 21, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here