Page 1 of 1

2.4. Customer (20%) The Customer class should store information about a customer's account. This includes ba- sic inform

Posted: Fri May 20, 2022 4:38 pm
by answerhappygod
2 4 Customer 20 The Customer Class Should Store Information About A Customer S Account This Includes Ba Sic Inform 1
2 4 Customer 20 The Customer Class Should Store Information About A Customer S Account This Includes Ba Sic Inform 1 (164.44 KiB) Viewed 26 times
2.4. Customer (20%) The Customer class should store information about a customer's account. This includes ba- sic information such as their account ID (a 6 digit alphanumeric identifier), their name, their age (a whole number in years), their level of personal discount (none, CMP staff, or student), and their account balance (as an integer in pence, e.g. 1001 for £10.01). You should have two constructors, one for ID, name, age and discount type only that sets a default balance of zero, and another constructor that takes arguments for all fields including a specified balance (but the initial balance must be at least zero). The account balance is the amount of money that is in a customers account and it will be reduced appropriately each time a customer uses an arcade game (see the chargeAccount method below). A customer's balance should never be allowed to become negative - with the only exception that those with a student discount are also allowed to have a balance that goes as low as -500 (similar to an overdraft), and it would not be sensible to allow a negative starting balance for an account. Therefore, your construc- tors should throw an InvalidCustomerException if the account ID is incorrect or a negative balance is provided (you will need to provide this Exception class). Your class should include accessors for all fields and two methods for manipulating the bal- ance of an account - one to add to the balance and one to simulate accounts being charged. • First, the addFunds (int amount) method should allow a customer to top-up their ac- count balance (only add a positive amount to a balance and do not alter the balance if a negative amount is provided).

• Second, there should be an instance method called chargeAccount that is used to sim- ulate a customer using an arcade game. This method should take two arguments, where one is an arcade game object and the other is a boolean to determine whether the ac- count is being charged during peak time. If a customer has a sufficient balance and is old enough to use an arcade game then the method should operate successfully and re- turn an int equal to the amount that the customer was charged (after any applicable discounts - remember, there are off-peak discounts for some games and CMP Staff re- ceive an additional 10% discount while students receive an additional 5% discount. Again, round down to the nearest integer if necessary when calculating prices). If the customer does not have sufficient funds to use the arcade game then their balance should be left unaltered and an InsufficientBalanceException should be thrown. Similarly, if the customer is not old enough to use the arcade game, their balance should be left unal- tered an a AgeLimitException should be thrown (you will need to create both of these sub-classes of Exception). Finally, ensure that your class also includes a suitable toString, helpful comments and evi- dence of testing. (Note: in practice, a customer's age would not be stored as an int and would likely be rep- resented by their date of birth. To keep it simple in this assignment though we are fixing it to be an int however and you can assume a customer's age will not change during the execution of your program).

748A66#Lucille Swan#800#31#STAFF 106498#Barry Guy#O#17 305459#Lewie King#3200#47 203685#Lois Romero#360#41#STAFF SGRQO1#Thea Worthington#800#17 889027 #Mikel Flinn#200#18#STUDENT 117DA4#Roshni Stephens#1000#15 6048D1#Macauly Rutledge#1400#37#STUDEN 512X13#Charles James-Warne#10#12 A64248#Amanda Pham#100#45 144374#Edwin Shea#100#24 546R82#Aman Crosby#380#62#STAFF 174450#Jonathan Wordle#200#19#STUDENT 2612CX#Kiri Kramer#3400#38 518370#Charis Jaramillo#3200#19#STUDEN 264474#Rowena Kaiser#1600#19#STUDENT 54A0N3#Moses Rivers#1000#20#STUDENT 506VX5#Catherine Chives-Keller#400#15 343172#Nour Buxton#1200#5 356965#Amy Mckinney#4000#17 522136#Khloe Stokes#1000#6 985F83#Jorge Pimento#200#23#STUDENT 901420#Paige Barclay#140#29 738164#Aoife Crouch#1000#29 9F0610#Aurora Mcleod#260#39#STAFF 387036#Irene Freeman#240#10 58R526#John-Paul clay#400#47#STAFF 973SA2#Jimmy Baker#1000#4 555765#Maaria Crossley#400#39#STAFF