Chat with us, powered by LiveChat Programming Logic | Wridemy

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.

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Wridemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order

Related Tags

Academic APA Writing College Course Discussion Management English Finance General Graduate History Information Justify Literature MLA