a) Design a class named PhoneCall with four field%u2019s: two strings that hold
ID: 3536653 • Letter: A
Question
a) Design a class named PhoneCall with four
field%u2019s: 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
number and call length fields, but do not include a set methods for
the phone number and call length fields, but do the cost of the
call at three cents per minute for the first 10 minutes, and two
center per subsequent minute. Create the class diagram and
write the pseudocode that defines the class.
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 defaut value
supplied by the constructor. Then, display each PhoneCall's
value.
c) Create a child class named
InternationalPhoneCall. Overried the parent class method that sets
the call length to calculate the cost of the call at 40 cents per
minute.
d) Crete the logic for an application that
instantiates a PhoneCall object and an InternationalPhoneCall
object and displays the cost for both.
I only need C and D
Here is the answers for Part A and part B, I just need part C and D (*********** I NEED A Pseudocode********)
A...
B...
start
Declarations
PhoneCall
callOne
PhoneCall callTwo
PhoneCall callThree
callOne.setLength(10)
callTwo.setLength(11)
output
%u201C
PhoneCall
1 info:%u201D
output
%u201COriginating number = %u201D,
callOne.getOrigCall()
output
%u201CReceiving number = %u201D, callOne.getRecCall()
output
%u201CCall length = %u201D, callOne.getLength()
output %u201CCall cost = %u201D, callOne.getCost()
output
%u201C
PhoneCall
2
info:%u201D
output
%u201COriginating number = %u201D, callTwo.getOrigCall()
output
%u201CReceiving number = %u201D, callTwo.getRecCall()
output
%u201CCall length = %u201D, callTwo.getLength()
output %u201CCall cost = %u201D, callTwo.getCost()
output
%u201C
PhoneCall
3
info:%u201D
output
%u201COriginating number = %u201D,
Explanation / Answer
Part C:
you need to do Inheritance.
public class InternationalPhoneCall extends PhoneCall {
}
declare INTERNATIONAL_RATE = .40
inside this class you need to override the call_cost calculation method.
cost = INTERNATIONAL_RATE * length;
Part D:
PhoneCall p1 = new PhoneCall();
p1.displayCost();
InternationalPhoneCall ip1 = new InternationalPhoneCall();
ip1.displayCost();
Rest of the logic should be same as for PhoneCall.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.