Description
Introduction:
We are all living in a world that technological revolutions occur almost every
day. One of the most important revolution was ,of course, the Communication
Systems. Today, you’re going to implement a simple version of a communication
system.
There will be Customers, Operators, and Bills that belong to the Customers.
Customers can talk to each other, message each other, or they can connect to the
internet via their mobile phones. Operators have their unique costs for the
corresponding actions that will be given to you in the input. Every customer will have
their unique Bill that stores and do the necessary actions about their spending.
You’re going to take the input as an input file, do the operations, and will print
out the necessary information to the output file. There will be no System.in arguments,
in other words, there will not be any input given with the keyboard while the program
runs.
Note that there will be multiple classes, (Not like in CMPE150 ) Therefore, think
a little bit about the structure before starting to implementing program.
Field and Method names that given to you in this Document must be identical
in terms of names and structures in your Project. That doesn’t mean that you can not
add extra Methods or Fields.
Classes and Implementation Details:
There will be 4 classes interacting with each other in this Project.
Main
Customer
Operator
Bill
Note that, it will be better to do the necessary calculations via using corresponding
methods in the Customer, Operator or Bill class, not in the main Class. Some parts of
the main class are given to you(input – output oerations) but, other 3 classes are given
completely empty. You’re expected to fill these classes with the given directions.
Main.java:
Main Class is for the general input – output operations. You are going to read an
input file that contains directions about the simulation and do the several actions,
then you will print out the desired results into the output file. These directions will be
explained in a detailed way, later on this document. Name of the input and output files
will be given as arguments of the program. For the input-output test cases, we are
going to use your main class.
There will be 2 arrays in the main method as follows:
Customer[] customers
Operator[] operators
You are going to store the corresponding data in these arrays. All of these arrays
must be initialized and, all of the elements in these arrays must be set to “null” as
default. You’re going to edit these arrays whenever a new object is created.
Customer.java:
Customer Class must have the following fields, exactly as named below:
int ID
String name
int age
Operator operator
Bill bill
Customer class must have the following methods with the exact parameters:
A constructor with five parameters: int ID, String name, int age , Operator
operator, double limitingAmount
void talk(int minute, Customer other) for customers to talk via the operator.
Other is the another customer, mainly the second customer.
void message(int quantity, Customer other) for customers to send message,
amount is the number of messages to be sent. Other is the another customer,
mainly the second customer.
void connection(double amount) for customers to connect the internet.
Amount is the number of data as MB.
Getter and setter methods for age,operator,and bill. Ex: getAge (), setAge(int
age)
Operator.java:
Operator class should have these fields with the exact names:
int ID
double talkingCharge
double messageCost
double networkCharge
int discountRate
Operator class should have the following methods with the given parameters:
A constructor with 5 parameters: ID, talkingCharge, messageCost,
networkCharge, discountRate
double calculateTalkingCost(int minute, Customer customer) for calculating
the total amount to pay for talking.
double calculateMessageCost(int quantity, Customer customer, Customer
other) for calculating the total amount to pay for talking.
double calculateNetworkCost(double amount) for calculating the total amount
to pay for talking
Getter and setter methods for talkingCharge, messageCost, networkCharge,
discountRate
Bill.java:
Bill class must have the following fields:
double limitingAmount
double currentDebt
Bill Class must have the following methods with the exact parameters:
Constructor with 1 parameter: limitingAmount. Note that you should initialize
the currentDebt as zero.
boolean check(double amount) is for checking whether the limitingAmount is
exceeded or not.
void add(double amount) is for adding debts to the bill.
void pay(double amount) is for paying the bills with the given amount.
void changeTheLimit(double amount) this method is for changing the limiting
Amount.
Getter methods for limitingAmount and currentDebt
Input Format:
You’re going to read the input file line by line or token by token. First 3 lines
will be integers. In the first line, the number “C” represents the number of customers
will be in this Project. The second line has the number “O” which tells you that the
number of Operators in the Project. In the third line, the number “N” will represent
the number of events that are going to be simulated.
Next N lines are going to be operations with the given rules.
1-Creating a new Customer
2-Creating a new Operator
3-A customer can talk to another customer
4-A customer can send message to another customer
5-A customer can connect to the internet
6-A customer can pay his/her bills.
7-A customer can change his/her operator
8-A customer can change his/her Bill limit
Input 1 : Creating a new Customer
This line contains a String name, an int age, an int ID as operator ID, double as
the limiting amount.
1 Example : 1 Ahmet 20 4 100 (This creates a customer with the name Ahmet,
age 20, and uses the operator with the ID 4, and has a bill with 100 limitingAmount)
Note that, id of the customer should be in the order of creation. To illustrate,
first created customer must have ID 0 and the location in the array of that customer
should be on his/her ID. Also there is no operation to create a bill object, therefore you
need to create in the Customer class and store the bill object whenever you are going
to create a customer.
Input 2 : Creating a new Operator
This Input line is followed by 3 doubles and 1 integer respectively, double
talkingCharge, messageCost, networkCharge, int discountRate
2 CMPE 160
Example : 2 1.2 0.48 0.15 15 (This creates an Operator object with 1.2/minute
talking charge, 0.48/message messaging cost, 0.15/1MB network usage charge, %15
discount rate that will be applied to the proper customers)
Creation of an Operator object. Again, ID of the operator must be in the order
of creation.
Input 3 : A customer talks to another customer
This line is followed by 3 integers that represents respectively, ID of the first
customer, ID of the second customer , time as an integer.
3<1stCustomerID><2ndCustomerID>



