Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

https://github.com/Seneca-244200/OOP-Project/tree/main/MS4 The... https://github.com/Seneca-244200/OOP-Project/tree/main/MS4 The CovidPatient module This module has one integer global variable callednextCovidTicketthat is initialized toone. This global variable will be used to determine

https://github.com/Seneca-244200/OOP-Project/tree/main/MS4 The...

https://github.com/Seneca-244200/OOP-Project/tree/main/MS4

The CovidPatient module

This module has one integer global variable callednextCovidTicketthat is initialized toone. This global variable will be used to determine what is the ticket number of the next COVID test Patient. Each time a newCovidPatientobject is created the value of thenextCovidTicketwill be increased byone. The scope of the globalnextCovidTicketvariable is only theCovidPatientmodule to make sure that the ticket numbers of Covid patients are kept separate from the Triage patients.

TheCovidPatientclass is publicly derived from thePatientclass. TheCovidPatientclass does not add any member variables or properties to thePatientmodule.

TheCovidPatientclass has onedefault constructor, implements the pure virtualtype()function and re-implements the tworeadfunctions and thewritefucniton of the base classPatientas follows:

Default Constructor

Sets the Ticket number to the current global value and then increases the global value by one.

implementation

The default constructor passes thenextCovidTicketglobal variable to theconstructorof the base classPatientand then it will increase the value ofnextCovidTicketglobal variable byone.

The type() virtual function

Identifies the Patient object as a Covid patient by returning the letterC.

implementation

This function only returns the character'C';

csvRead virtual function override

Reads a comma-separated record of a Patient and sets the global ticket number to the next number after the Patient's ticket number.

implementation

First this function will call thecsvReadfunction of the base classPatient, afterwards it will set thenextCovidTicketglobal variable to the return value of thenumber()function of thePatientclass plusone. Then it will ignore the terminating'n'character. Finally, it will return the istream reference.

write virtual function override.

Based on the return value of thefileIOmethod it will either write the patient in a comma-separated format or a descriptive format for screen or ticket.

implementation

If thefileIOmember function returnstrue, it will call thecsvWritefunction of the base class, otherwise it will first insert"COVID TEST"into theostreamobject and goes tonewline. Then it will call thewrite()function of the base class and then goes tonewline.

Then it will end the function by returning theostreamreference.

read virtual function override.

Based on the return value of thefileIOmethod it will either read the patient in a comma-separated format from istream or perform a fool-proof entry from the console.

implementation

If thefileIOmember function returns true it will call thecsvReadfunction, otherwise, it will call the read function of the base class.

Then it will end the function by returning theistreamreference.

Destructor

This class does not need a destructor.

the CovidPatient Tester (CPTester.cpp) output

Testing CovidPatient: Enter the following: Enter current time: 12:34 Name: aaa OHIP: 111111111 Enter current time: 12:34 Enter Patient information: Name: aaa OHIP: 111111111 Enter the following: Enter current time: 12:35 Name: bbb OHIP: 222222222 Enter current time: 12:35 Enter Patient information: Name: bbb OHIP: 222222222 Patients information entered: COVID TEST Ticket No: 1, Issued at: 12:34 aaa, OHIP: 111111111 COVID TEST Ticket No: 2, Issued at: 12:35 bbb, OHIP: 222222222 CSV output: C,aaa,111111111,1,12:34 C,bbb,222222222,2,12:35 Testing CSV input: Enter the following: >ccc,333333333,10,23:45 >ccc,333333333,10,23:45 Data entered: COVID TEST Ticket No: 10, Issued at: 23:45 ccc, OHIP: 333333333 Testing global ticket number variable: Enter the following: Enter current time: 23:55 Name: ddd OHIP: 444444444 Enter current time: 23:55 Name: ddd OHIP: 444444444 Patient information entered: COVID TEST Ticket No: 11, Issued at: 23:55 ddd, OHIP: 444444444 

The TriagePatient Module

This module has one integer global variable callednextTriageTicketthat is initialized toone. This global variable will be used to determine what is the ticket number of the next triage Patient. Each time a newTriagePatientis created the value of thenextTriageTicketwill be increased byone. The scope of the globalnextTriageTicketvariable is only the TriagePatient module.

TheTriagePatientclass is publicly derived from thePatientclass. TheTriagePatientclass adds only one character pointer member variable to thePatientmodule to dynamically hold the symptoms of the arriving patient for the triage centre.

TheTriagePatientclass has onedefault constructor, implements the pure virtualtype()function and re-implements the fourread and writefunctions of the base classPatient. It also has a destructor to make sure the dynamically allocated memory by the symptoms character array is deleted.

Symptoms character pointer member variable

DO a character pointer member variable to point to a dynamically allocated Cstring holding the list of the symptoms of the TriagePatient.

Default Constructor

Initializes the symptoms character pointer to null and then sets the Triage Ticket number to the current global value and then increases the global value by one.

implementation

The default constructor initializes the character pointer member variable to null and then passes thenextTriageTicketglobal variable to theconstructorof the base classPatientand then it will increase the value ofnextTriageTicketglobal variable byone.

the type() virtual function

Identifies the Patient object as a Triage patient by returning the letterT.

implementation

This function only returns the character'T';

csvWrite virtual function override.

Adds the symptoms to the comma-separated values of the patient.

implementation

This function calls thecsvWritefunction of the base classPatientthen inserts a comma (',') character into the ostream object and then the symptoms of the patient. Finally, it returns theostreamreference.

the csvRead virtual function override

Reads a comma-separated record of a triage Patient and sets the global ticket number to the next number after the Patient's ticket number.

implementation

csvRead reads the TriagePatient's comma-separated information as follows:

  • Deletes the memory pointed by thesymptoms member variable
  • Calls thecsvReadfunction of the base class.
  • Ignores a character (comma).
  • Dynamically reads a Cstring from the istream object up to'n', then extracts the'n'from the istream and stores the address in thesymptoms member variable;
  • sets thenextTriageTicketglobal variable to the return value of the number() member function of the Patient class plus one.
  • returns the istream reference.

write virtual function override.

Based on the return value of thefileIOmethod it will either write the patient in a comma-separated format or a descriptive format for screen or ticket.

implementation

If thefileIOmember function returnstrue, it will callcsvWritefunction. otherwise, it will write the TriagePatient as follows:

  • Inserts"TRIAGE"into theostreamobject.
  • Goes tonewline.
  • It will call thewrite()function of the base classPatient.
  • Goes tonewline.
  • Inserts"Symptoms: "into the ostream object.
  • Inserts the symptoms member variable into the ostream object.
  • Goes to newline.

The function ends by returning theostreamreference.

read virtual function override.

If thefileIOmember function returns true it will call thecsvReadfunction, otherwise, it will do the following:

  • Deletes the memory pointed by thesymptoms member variable
  • Calls theReadfunction of the base classPatient.
  • prompts:"Symptoms: "-Dynamically reads a Cstring from the istream object up to'n', then extracts the'n'from the istream and stores the address in thesymptoms member variable

The function ends by returning theistreamreference.

Destructor

Deletes the memory pointed by thesymptoms member variable

The TriagePatient Tester (TPTester.cpp) output

Testing TriagePatient: Enter the following: Enter current time: 12:34 Name: aaa OHIP: 111111111 Symptoms: aaa aaa aaa Enter current time: 12:34 Enter Patient information: Name: aaa OHIP: 111111111 Symptoms: aaa aaa aaa Enter the following: Enter current time: 12:35 Name: bbb OHIP: 222222222 Symptoms: bbb bbb bbb Enter current time: 12:35 Enter Patient information: Name: bbb OHIP: 222222222 Symptoms: bbb bbb bbb Patients information entered: TRIAGE Ticket No: 1, Issued at: 12:34 aaa, OHIP: 111111111 Symptoms: aaa aaa aaa TRIAGE Ticket No: 2, Issued at: 12:35 bbb, OHIP: 222222222 Symptoms: bbb bbb bbb CSV output: T,aaa,111111111,1,12:34,aaa aaa aaa T,bbb,222222222,2,12:35,bbb bbb bbb Testing CSV input: Enter the following: >ccc,333333333,10,23:45,ccc ccc ccc >ccc,333333333,10,23:45,ccc ccc ccc Data entered: TRIAGE Ticket No: 10, Issued at: 23:45 ccc, OHIP: 333333333 Symptoms: ccc ccc ccc Testing global ticket number variable and DMA: Enter the following: Enter current time: 23:55 Name: ddd OHIP: 444444444 Copy and paste the follwoing for Symptoms: Socks Box Knox Know in box. Fox in socks. Knox on fox In socks in box. Socks on Knox And Knox in box. Fox in socks On box on Knox. Chicks with bricks come. Chicks with blocks come. Chicks with Bricks and Blocks and clocks come. Look, sir.Look, sir. Mr Knox, sir. Let's do tricks with Bricks and blocks, sir. Let's do tricks with Chicks and clocks, sir. First, I'll make a Quick trick brick stack. Then I'll make a Quick trick block stack. Enter current time: 23:55 Name: ddd OHIP: 444444444 Symptoms: Socks Box Knox Know in box. Fox in socks. Knox on fox In socks in box. Socks on Knox And Knox in box. Fox in socks On box on Knox. Chicks with bricks come. Chicks with blocks come. Chicks with Bricks and Blocks and clocks come. Look, sir.Look, sir. Mr Knox, sir. Let's do tricks with Bricks and blocks, sir. Let's do tricks with Chicks and clocks, sir. First, I'll make a Quick trick brick stack. Then I'll make a Quick trick block stack. Patient information entered: TRIAGE Ticket No: 11, Issued at: 23:55 ddd, OHIP: 444444444 Symptoms: Socks Box Knox Know in box. Fox in socks. Knox on fox In socks in box. Socks on Knox And Knox in box. Fox in socks On box on Knox. Chicks with bricks come. Chicks with blocks come. Chicks with Bricks and Blocks and clocks come. Look, sir.Look, sir. Mr Knox, sir. Let's do tricks with Bricks and blocks, sir. Let's do tricks with Chicks and clocks, sir. First, I'll make a Quick trick brick stack. Then I'll make a Quick trick block stack. 

The tester program.

Read and study the tester program and understand how it works.

ms4Tester.cpp

The ms4Tester program is the execution of both modules combined.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

How can wage surveys be effectively used in collective bargaining?

Answered: 1 week ago