Details of this Paper

Programming Logic




1. Find the bugs(5bugs);// A Patient class is used by a doctor's office.;// The Patient class has two overloaded constructors;// 1) a default constructor;// 2) one that requires an ID number, first and last name.;// A demonstration program declares two Patient objects;// and displays each patient's data fields.;start;Declarations;Patient patient1();Patient patient2("234", "Lee", "Lydia");patient1.display();patient2.display();stop;class Patient;Declarations;private string idNum;private string lastName;private string firstName;public Patient();idNum = "0000";lastName = "XXXX;firstName = "XXXX;return;public Patient(string id, string last, string first);idNum = idNum;last = last;firstName = first;return;public void display();output "Patient #", id, lastName, firstName;return;end;2. 2a and 2b were shown or done in class. 2c & 2d are for your homework;a. Design a class named PhoneCall with four fields: two strings that hold the 10-digit phone;numbers that originated and received the call, and two numeric fields that hold the length of the;call in minutes and the cost of the call. Include a constructor that sets the phone numbers to Xs;and the numeric fields to 0. Include get and set methods for the phone numbers and call length;fields and a get method for the cost, but do not include a set method for the cost field. When;the call length is set, calculate the cost of the call at three cents per minute for the first 10;minutes, and two cents per subsequent minute. Create the class diagram and write the;pseudocode that defines the class.;Answer: A sample solution follows;Diagram;PhoneCall;-origCall: string;-recCall: string;-length: num;-cost: num;+PhoneCall();+setOrigCall(number: string): void;+setRecCall(number: string): void;+setLength(len: num): void;+getOrigCall(): string;+getRecCall(): string;+getLength(): num;+getCost(): num;Pseudocode;class PhoneCall;Declarations;private string origCall;private string recCall;private num length;private num cost;public PhoneCall();origCall = ?XXXXXXXXXX?;recCall = ?XXXXXXXXXX?;length = 0;cost = 0;return;public void setOrigCall(string number);origCall = number;return;public void setRecCall(string number);recall = number;return;public void setLength(num len);Declarations;num LIMIT = 10;num LIMIT_OR_LESS =.03;num MORE_THAN_LIMIT =.02;length = len;if length > LIMIT then;cost = (LIMIT_OR_LESS * LIMIT) +;(MORE_THAN_LIMIT * (length ? LIMIT));else;cost = LIMIT_OR_LESS * length;endif;return;public string getOrigCall();return origCall;public string getRecCall();return recCall;public num getLength();return length;public num getCost();return cost;endClass;b. Design an application that declares three PhoneCalls. Set the length of one PhoneCall;to 10 minutes, another to 11 minutes, and allow the third object to use the default value;supplied by the constructor. Then, display each PhoneCall?s values.;Answer: A sample solution follows;Pseudocode;start;Declarations;PhoneCall callOne;PhoneCall callTwo;PhoneCall callThree;callOne.setLength(10);callTwo.setLength(11);output ?PhoneCall 1 info:?;output ?Originating number = ?, callOne.getOrigCall();output ?Receiving number = ?, callOne.getRecCall();output ?Call length = ?, callOne.getLength();output ?Call cost = ?, callOne.getCost();output ?PhoneCall 2 info:?;output ?Originating number = ?, callTwo.getOrigCall();output ?Receiving number = ?, callTwo.getRecCall();output ?Call length = ?, callTwo.getLength();output ?Call cost = ?, callTwo.getCost();output ?PhoneCall 3 info:?;output ?Originating number = ?, Chapter 11 ? Part 2, Exam Question #2 ? Fall 2013;callThree.getOrigCall();output ?Receiving number = ?, callThree.getRecCall();output ?Call length = ?, callThree.getLength();output ?Call cost = ?, callThree.getCost();stop;Here is your assignment using the above 2a and 2b as the starting point/basis;c. Create a child class named InternationalPhoneCall. Override the parent class;method that sets the call length to calculate the cost of the call at 40 cents per minute.;Create the Class Diagram for the child class and write the pseudocode for the child;class.;d. Create the logic for an application that instantiates a PhoneCall object and an;InternationalPhoneCall object and displays the costs for both.


Paper#71058 | Written in 18-Jul-2015

Price : $27