- Engineering
- Computer Science
- a c question problem statement you are asked to develop...
Question: a c question problem statement you are asked to develop...
Question details
A c++ question,
Problem Statement
you are asked to develop a walk-in clinic patient system. The goal of this system is to manage the medical records of all the patients of the walk-in clinic.
The walk-in clinic keeps the following information about all its patients: the patient's name (first and last name), address, phone number, email address and care card number.
The walk-in clinic patient system must allow the receptionist to
- enter a new patient into the system
- remove a patient from the system
- search for an existing patient
- modify a patient's record (for example, adding the patient's information or making a change of address, etc...).
- print all its patients by ascending order of care card numbers.
I've written the patient.h patient.cpp list.h list.cpp(maybe they need some modify), please help me finish main function walkIn.cpp.
#pragma once
// You can add #include statements if you wish.
#include<iostream>
#include <string>
using namespace std;
class Patient {
private:
string name;
string careCard;
string address;
string phone;
string email;
// There are plenty of hints in the provided files to help you complete this section.
public:
/*
* You can add more methods to this public interface,
* but you cannot remove the methods below
* nor can you change their prototype.
*
*/
// Default Constructor
// Description: Create a patient with a care card number of "0000000000".
// Postcondition: All data members set to "To be entered",
// except the care card number which is set to "0000000000".
Patient();
// Parameterized Constructor
// Description: Create a patient with the given care card number.
// Postcondition: If aCareCard does not have 10 digits, then care card is set to "0000000000".
// All other data members set to "To be entered".
Patient(string aCareCard);
// Getters and setters
// Description: Returns patient's name.
string getName() const;
// Description: Returns patient's address.
string getAddress() const;
// Description: Returns patient's phone.
string getPhone() const;
// Description: Returns patient's email.
string getEmail() const;
// Description: Returns patient's care card.
string getCareCard() const;
// Description: Sets the patient's name.
void setName(const string aName);
// Description: Sets the patient's address.
void setAddress(const string anAddress);
// Description: Sets the patient's phone.
void setPhone(const string aPhone);
// Description: Sets the patient's email.
void setEmail(const string anEmail);
// Overloaded Operators
// Description: Comparison operator. Compares "this" Patient object with "rhs" Patient object.
// Returns true if both Patient objects have the same care card number.
bool operator == (const Patient & rhs);
// Description: Greater than operator. Compares "this" Patient object with "rhs" Patient object.
// Returns true if the care card number of "this" Patient object is > the care card
// number of "rhs" Patient object.
bool operator > (const Patient & rhs);
// Description: Prints the content of "this".
friend ostream & operator<<(ostream & os, const Patient & p);
}; // end of Patient.h
// You can add #include statements if you wish.
#include <iostream>
#include <string>
#include "Patient.h"
// Default Constructor
// Description: Create a patient with a care card number of "0000000000".
// Postcondition: All data members set to "To be entered",
// except the care card number which is set to "0000000000".
Patient::Patient() {
name = "To be entered";
address = "To be entered";
phone = "To be entered";
email = "To be entered";
careCard = "0000000000";
// You need to complete this method.
}
// Parameterized Constructor
// Description: Create a patient with the given care card number.
// Postcondition: If aCareCard does not have 10 digits, then care card is set to "0000000000".
// All other data members set to "To be entered".
Patient::Patient(string aCareCard) {
// You need to complete this method.
if (aCareCard.length() < 10) {
careCard = "0000000000";
name = "To be entered";
address = "To be entered";
phone = "To be entered";
email = "To be entered";
}
else {
careCard = aCareCard;
}
}
// Getters and setters -> You need to implement these methods.
string Patient::getAddress()const {
return address;
}
string Patient::getName()const {
return name;
}
string Patient::getPhone()const {
return phone;
}
string Patient::getEmail()const {
return email;
}
string Patient::getCareCard()const {
return careCard;
}
void Patient::setName(const string aName) {
name = aName;
}
void Patient::setAddress(const string anAddress) {
address = anAddress;
}
void Patient::setPhone(const string aPhone) {
phone = aPhone;
}
void Patient::setEmail(const string anEmail) {
email = anEmail;
}
// Overloaded Operators
// Description: Comparison operator. Compares "this" Patient object with "rhs" Patient object.
// Returns true if both Patient objects have the same care card number.
bool Patient::operator == (const Patient & rhs) {
// Compare both Patient objects
if (this->careCard == rhs.getCareCard() )
return true;
else
return false;
} // end of operator ==
// Description: Greater than operator. Compares "this" Patient object with "rhs" Patient object.
// Returns true if the care card number of "this" Patient object is > the care card
// number of "rhs" Patient object
bool Patient::operator > (const Patient & rhs) {
// Compare both Patient objects
if (this->careCard > rhs.getCareCard() )
return true;
else
return false;
} // end of operator >
// Description: Prints the content of "this".
ostream & operator<<(ostream & os, const Patient & p) {
// You need to complete this method.
os << p.careCard << " - Patient:" << p.name<<"," << p.address << "," << p.phone << "," << p.email << "," << endl;
return os;
} // end of operator<<
#pragma once
// You can add #include statements if you wish.
#include <string>
#include<iostream>
#include "Patient.h"
using namespace std;
class List {
private:
/*
* You can add more attributes to this class,
* but you cannot remove the attributes below
* nor can you change them.
*/
static const int MAX_ELEMENTS = 5; // Small capacity so can test when data collection becomes full
// ***As we are testing the code of our assignment, we can
// change the value given to this constant.***
Patient elements[MAX_ELEMENTS]; // Data structure with capacity of MAX_ELEMENTS
int elementCount; // Current element count in element array
int capacity; // Actual maximum capacity of element array
public:
/*
* You can add more methods to this interface,
* but you cannot remove the methods below
* nor can you change their prototype.
*
*/
// Default constructor
List();
// Description: Returns the total element count currently stored in List.
int getElementCount() const;
// Description: Insert an element.
// Precondition: newElement must not already be in data collection.
// Postcondition: newElement inserted and elementCount has been incremented.
bool insert(const Patient& newElement);
// Description: Remove an element.
// Postcondition: toBeRemoved is removed and elementCount has been decremented.
bool remove( const Patient& toBeRemoved );
// Description: Remove all elements.
void removeAll();
// Description: Search for target element.
// Returns a pointer to the element if found,
// otherwise, returns NULL.
Patient* search(const Patient& target);
}; // end List.h
#include <iostream>
#include <string>
#include "List.h"
using namespace std;
List::List() {
elementCount = 0;
capacity = 0;
}
List::~List() {
}
int List::getElementCount() const {
/*int count = 0;
for (int i = 0; i < MAX_ELEMENTS) {
count += elementCount;
}
return count;*/
return elementCount;
}
bool List::insert(const Patient& newElement) {
for (int i = 0; i < elementCount; i++) {
if (elements[i] == newElement) {
return false;
}
}
if (elementCount <= capacity) {
elements[elementCount] = newElement;
elementCount += 1;
}
}
bool List::remove(const Patient& toBeRemoved) {
for (int i = 0; i < elementCount; i++) {
if (elements[i] == toBeRemoved) {
swap(elements[i], elements[elementCount - 1]);
elementCount -= 1;
return true;
}
}
return false;
}
void List::removeAll() {
/*for (int i = 0; i < elementCount; i++) {
elements[i] = "NULL";
}*/
elementCount=0;
}
Patient* List::search(const Patient& target) {
for (int i = 0; i < elementCount; i++) {
if (elements[i] == target)
return &elements[i];
}
return NULL;
}
Solution by an expert tutor
