Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[16 points) Write a class Customer which has the following private fields: - A String name - An int representing the balance in cents) of
[16 points) Write a class Customer which has the following private fields: - A String name - An int representing the balance in cents) of the customer - A Basket containing the reservations the customer would like to make. The class must also have the following public methods: - A constructor that takes as input a String indicating the name of the customer, and an int representing their initial balance. The constructor uses its inputs and creates an empty Basket to initialize the corresponding fields. - A getName and a getBalance method which return the name and balance in cents) of the customer respectively. A get Basket method which returns the reference to the basket of the customer (no copy of the basket is needed). An addFunds method which takes an int as input reprezenting the amount of cents to be added to the balance of the customer. If the input received is negative, the method should throw an IllegalArgumentException with an appropriate message. Otherwise, the method will simply update the balance and return the new balance in cents
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started