Lab 1: Best Buy Inventory Program
Due Date and Submission Requirements
- Due Date: Thursday, August 29th at 11:59 p.m.
- Partner Information: This is an individual assignment. You are allowed to collaborate with other students, but each student must submit their individual, independent solution.
- Submission Instructions: Upload your solution (.java file), entitled Item.java and Customer.javato the BrightSpace(D2L) Lab 1 Dropbox. Do not rename your .java files
The goal of this lab is:
- Write a basic Java class (Instance Fields, Methods, Constructor)
- Gain practice writing different kinds of methods
- Use if statements to check conditions
- Use loops and arrays
Background and Directions
Earlier this month, it was announced that Bozeman will be getting a Best Buy later this year. This is great news for people that need to shop for electronics and appliances. In this lab, we've been tasked with writing a program that will keep track of items that may be sold at a Best Buy store.
Using Lab1Demo.Java, as a starting point, you will supply the necessary classes and methods to get the correct output. You can download this file, or copy and paste it into your own Lab1Demo.java.
You first need to define the instance fields and constructor for the Item class. This represents an item that may be sold at a Best Buy. Each item will have:
- A name (such as "MacBook Air")
- A price (such at 10.99)
- A list of review scores stored in an array (such as [5.0, 4.0, 3.0, 1.0]). This array will have N amount of review scores, where N > 0
Once you have the class defined, you will need to write the necessary methods. From looking at the Demo class, you should be able to see which ones you need.
In the Item class, you will need to define the following methods:
- getName()- returns the name of an item
- getPrice()- returns the price of an item
- getAverageRating()- returns the average review score from the array of review scores
Next, you will define the Customer class. This represents a customer that may be purchasing items from a Best Buy. Each customer will have:
- A name
- A cart of items that they intend to purhcase. This will be an array of Items
Once you have the class and constructor defined, you will need to implement the following methods:
- getName()- returns the name of a customer
- getCartCost()- returns the total cost of the customers cart. You will need to use a loop to total the price of each Item in the array
- applyDiscounts()- Best Buy is running a sale. 20% off will be applied to every item that is $200. This method will need to go through the customer's cart, and apply the discount to the applicable items, which will update the price of an item. Hint: You may need to write a setPrice() method in the Item class
The cart total may have three decimal places, which is fine. In Java, there are ways to only allow two decimal places, but that is not a requirement in this assignment.
Rules
You are NOT allowed to modify Lab1Demo.java. If you modify Lab1Demo.Java in any way, then you will lose significant points!
Starting Code
Required Output
When your program is run, your output should look exactlythe same as seen in this screenshot .
Grading (10 points)
- 2 points - Your Item class is correctly defined, and has a working constructor method
- 2 points - Methods in Item class are correct
- 2 point - Your Customer class is correctly defined, and has a working constructor
- 3 points- Methods in the Customer class are correct
- 1 point- your program matches the sample output exactly