Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed
[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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions