Question: Hi tutor, I need help for those three pure virtual function overwrites. std::istream& Patient::csvRead(std::istream& istr) std::ostream& write(std::ostream& ostr)const; std::istream& read(std::istream& istr); csvRead The csvRead function

Hi tutor, I need help for those three pure virtual function overwrites.

std::istream& Patient::csvRead(std::istream& istr)

std::ostream& write(std::ostream& ostr)const;

std::istream& read(std::istream& istr);

csvRead

The csvRead function extracts all the values in the same order as the csvWrite function, except for the type.

  • Start with the extraction with the name of the patient up to the comma (',') character and dynamically hold it in "the patient name pointer", dicarding the comma (',') delimiter .Make sure thatthe name pointeris deleted before the allocation to guarantee there is no memory leak.
  • then extract an integer from istream into the OHIP member variable.
  • discard the delimeter
  • Finally, end the extraction by calling the csvRead of the memberticket object.
  • return the istream reference at the end.

write

Inserts the patient information into the ostream to be displayed on the console.

  • insert the member [ticket object](#the-ticket into ostream
  • go to newline
  • insert the name
  • insert", OHIP: "
  • insert the OHIP number number
  • return the ostream

read

Extracts the ticket information from the console using istream as follows:

  • Prompt:"Name: "
  • Extract the name of the patient up to the newline (' ') character and dynamically hold it in "the patient name pointer", dicarding the newline(' ') delimiter .Make sure thatthe name pointeris deleted before the allocation to guarantee there is no memory leak.
  • Prompt:"OHIP: "
  • Extract the 9 digit OHIP number from istream; validate it and make sure it is 9 digits.
  • return the istream reference at the end.

This is my Patient Module for reference

namespace sdds {

class Patient :public IOAble {

char* p_name=nullptr;

int p_OHIP;

Ticket* p_ticket;

bool p_IOflag;

public:

//constructor, if int and bool is not provided, default 0 and false will be passed

Patient(int ticketNum = 0, bool IOflag = false);

//copy constructor and assignment are not allowed

Patient(const Patient&) = delete;

Patient& operator=(const Patient&) = delete;

~Patient();

//member functions

virtual char type()const = 0; //Pure Virtual Function type()

bool fileIO()const;

void fileIO(bool IOflag);

bool operator==(const char t)const;

bool operator==(const Patient&)const;

void setArrivalTime();

operator Time()const;

int number()const;

//pure virtual function overwrites.

std::ostream& csvWrite(std::ostream& ostr)const;

std::istream& csvRead(std::istream& istr);

std::ostream& write(std::ostream& ostr)const;

std::istream& read(std::istream& istr);

};

}

#endif // !SDDS_PATIENT_H_

Execution Sample

5 ----------------------------------------------- Ticket No: 14, Issued at: 12:54 A name that is way way wa, OHIP: 444444444 ms3out.csv----------------------- W,David Mason,111111111,10,12:50 W,Nick Gilmour,222222222,11,12:51 W,Roger Wright,333333333,12,12:52 W,Rick Waters,333333333,13,12:53 W,A name that is way way way way way way way way too long,444444444,14,12:54 --------------------------------- 

text.csv

David Mason 111111111 10 12:50

Nick Gilmour 222222222 11 12:51

Roger Wright 333333333 12 12:52

Rick Waters 333333333 13 12:53

A name that is way way way way way way way way too long 444444444 14 12:54

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!