You are on page 1of 6

CMS No.

______________
RIPHAH INTERNATIONAL UNIVERSITY
Faculty of Computing, WISH campus
Bachelor of Science in Software Engineering, -- Semester
End Term Examinations, Fall 2020
Course: Object Oriented Programming
Total marks: 30 (Practical Exam) Time Allowed: 10 hrs

Instructions: Attempt all questions.

You are required to build an application for a fictional telephone booth. The interface can be similar to the
following

This represents the administrator interface for a fictional telephone facility available in Islamabad/Rawalpindi
(Pakistan). You facility provides 4 types of calls including local (within rwp/ibd), truck (to other cities in
Pakistan) , overseas (to other countries .. possible option are given later in this document) and mobile (cell
phone dialing within the country)
Each type of call has different costing mechanism.
 Local calls have flat rate of Rs. 1/sec if the call is below 5 minutes and a flat cost of Rs. 10/call if the
call is above or equal to 5 minutes
 Mobile calls are charged at a flat Rs. 2/sec with an additional gst of 0.1 % of the call cost. I.e. if a mobile
call of 3 minutes is made then the cost is 2 * 180 = Rs. 360 and the total bill is cost + tax = 360 + (360
* .001) = Rs.360.36
 For Trunk Call each city has a different rate charged per second. The rates are given in Trunk Charges
table below. The total call bill is the call cost + additional exchange cost of flat Rs. 6. I.e. if a trunk call
to Lahore is made for 2.5 minutes then the call cost is 150 * 4 = Rs. 600 and the total call bill is 606
after adding the exchange fee.
 For the overseas calls, the per second rates to the available overseas destinations are given in Overseas
Charges table. The call bill is calculated by the call cost + flat Rs. 10 of exchange charges + 1% of the
call cost for the tax. So for a 5 minutes call to China will cost Rs. 30 * 300 = Rs. 9000 and the total call
bill would be call cost + exchange fee(Rs. 10) + tax (1% of call cost) = 900 + 10 + 9 = Rs.919

Your interface will allow the administrator to make necessary selections (details explained below), place the
call and note the start time. When the call is hung up, the time is noted again to get the duration of call in
seconds. Now based on the duration, costing is done and displayed in appropriate widgets on the screen.
Call are added to the log and can be saved to the file with all details. Explanation is given below

Please follow the given steps in order to complete your application

1. Design the GUI including necessary widgets to materialize the requirements. You can use the above
snapshot as a reference. Try using friendly and appropriate widgets.
a. On the GUI, you will have to enable/disable controls based on the current selections.
i. If local call is selected, the country code must be set to Pakistan and area code to
Islamabad. Then you will disable these combo boxes for any selection for the current
call. The local call only needs a number.
ii. If Trunk call option is chosen, you need to set country to Pakistan and disable this
widgets, the user can then choose the area/city as per wish and provide number to call
iii. If mobile call is selected then it works the same as for local call
iv. If overseas is selected, the user will have to make selection from each combo box and
give a number to dial
b. After the user has made necessary selections, when the place call button is pressed, the
system time should be recorded in the start time field, The hang up button will initially be
disabled but will become enabled when the place call button is pressed. Also place call itself
becomes disabled until the hang up will be pressed later.
i. Placing a call will also instantiate a call instance (appropriate based on the selected
type of the call from the radio buttons) and set the attributes to the appropriate values
recorded in the GUI (except for end time which will be set when hang up is pressed
later).
c. When hang up button is pressed, again the system time is recorded in the end time field and
also set on the Call instance created above. The duration will be calculated (method call
explained later) and displayed in the duration field. At the same time, you will display the
call cost and total bill.
d. After this, when the add to log button is pressed, the call instance (object) is added to the log
list and displayed the way done in the example interface (you know this can be acheieved by
manipulating the toString method).
e. If Save to file button is pressed, the records must be saved to the file but each type of call
will be recorded in corresponding file. I.e. you will have 4 file named local.txt, trunk.txt,
mob.txt and overseas.txt. Each call in the log will be saved to the appropriate file depending
upon the actual type of the call. (instanceof operator can help you here). So if the actual type
of the call is local (from the hierarchy below) then you will save all the info for it in the
local.txt and so on.
f. If remove is pressed, the selected call instance will be removed from the list
g. If show details is pressed, you will have to show all the details of the call in new JFrame
similar to following

2. For the Business/Application Layer, you will need to create a class Hierarchy similar to the
following

Call

Overseas
Local Call Trunk Call
Call

MobileCall

Call is the super class. This class has been implemented and provided in the attached link. You can
see the implementation for better understanding. Important methods are described below
1. Start() sets the starting time and returns string representation of the start time that you can use
in the GUI. Similarly end means when the call is hung up and returns the string representation of
this time.
2. GetDuration method returns the duration of the call in seconds.
3. getCallCost returns the cost of the call and is already implemented. Since its declared final, you
cannot override. You will only call it in your code where ever required. Similarity getCallBill is
also final and implemented correctly.
4. getAdditionalCost is the most important method which has been declared abstract in the parent
class. Each of the subclasses need to implement/override this method in order to get correct bill
of the call according to the requirements explained above.
3. Subclasses will introduce appropriate attributes of their own: For local calls you don’t need an
additional attribute. For mobile call you don’t need additional attribute. For trunk call you need to
give city name and for overseas call, you will have to add city and country (names). Provide
appropriate constructors
4. Each subclass must implement the getAdditionalCost method appropriately according to the
instructors given above.
5. You need to implement persistence of the data in 4 different files each containing record for local,
mobile, trunk and overseas call. For each instance you will Record following in the file
1. Number
2. Duration
3. Total bill
4. Destination (for trunk and overseas)

Trunk Call Charges


City Code Call rate/sec
Lahore 42 Rs. 5
Multan 61 Rs. 15
Faisalabad 41 Rs. 17
Karachi 69 Rs. 27

Overseas Call Charges


USA- 1 UK - 44 Turkey – 90
City Code Rates City Code Rates City Code Rates
Rs./ Rs./Min Rs./Min
Min
Washington 206 90 London 20 55 Ankara 312 100
New York 212 78 Birmingham 121 35 Istanbul 212 120
Texas 214 45 Manchester 161 60 Busra 214 125

Class CALL.java
import java.time.*;
/**
*
* @author Hajra Murtaza
*/
public class Call {
protected String number;
protected double callRate;
private Instant stTime;
private Instant endTime;
public Call(String number){
this.number = number;
}
public Call(String number, double rate){
this.number = number;
this.callRate = rate;
}
public String start(){
stTime = Instant.now();
return getStartTime();
}
public String end(){
endTime = Instant.now();
return getEndTime();
}
public String getStartTime(){
LocalDateTime l = LocalDateTime.ofInstant(stTime, ZoneId.systemDefault());
return l.getHour()+":"+l.getMinute()+":"+l.getSecond();

}
public String getEndTime(){
LocalDateTime l = LocalDateTime.ofInstant(endTime, ZoneId.systemDefault());
return l.getHour()+":"+l.getMinute()+":"+l.getSecond();

public String getNumber() {


return number;
}

public double getCallRate() {


return callRate;
}

public void setNumber(String number) {


this.number = number;
}

public void setCallRate(double callRate) {


this.callRate = callRate;
}

public long getDuration(){


Duration elapsed = Duration.between(stTime, endTime);
return elapsed.toMillis()/1000;
}
public final double getCallCost(){
return getDuration()* callRate;
}
public abstract double getAdditionalCost();
public final double getCallBill(){
return getCallCost() * getAdditionalCost();
}

Evaluation Rubric (Will be furnished in due time)

Criteria

Completion(5)

GUI(3)

Adherence to OO
Principles (3)

Separation of GUI,
Application and
Persistence code (3)

Syntactic Correctness
(2)

Logical Correctness
(3)

Originality of Work
(Through Demo and
Viva) (6)

You might also like