THIS IS JGRASP,JAVA.Given the following English language description of a prepai
ID: 666828 • Letter: T
Question
THIS IS JGRASP,JAVA.Given the following English language description of a prepaid mobile phone account, develop an Account class (Account.java) that uses a Plan class (Plan.java), and construct a test harness class that may be used to create an account and test its functions.
An account has a balance from which the cost of calls is deducted.
o Initially the balance is zero cents.
o An account can be ‘topped up’.
All monetary transactions are conducted in ZAR cents.
When the customer dials a number, their account is queried to determine the available airtime. (You may assume that calls are never allowed to exceed it.)
On completion of a call, given the duration, the account is updated.
The cost of calls/available air time is dictated by the account plan.
o A plan has a name.
o A plan has a cents per second call rate.
The customer can query their account.
Tips:
Identify the interface between Account and Plan objects and the rest of the mobile phone system.
Think about the best place for calculations and alterations of data to take place.
o For instance, if an Account object can delegate calculation of the cost of a call to its Plan object then it doesn’t need to know about call rates when updating the balance.
Think about appropriate operations on an account. For instance, given the description, an account balance can be topped up, it cannot be ‘set’.
If some aspect of behaviour is not described, then we don’t need it.
o For instance, you may assume that call rates are fixed for all time!
Your test harness does not need to be an ‘all singing and dancing’ affair. Hard code just enough to prove to yourself and a tutor that everything works.
Explanation / Answer
This is how we construct a test harness class that use to create account.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.