Brief Nowadays, consumers wield the power of the internet to shop for products online. A major factor in the consumer's decision-making process to purchase a product is its reliability, as determined by other consumers who have already purchased the product. In this assignment, you will individually develop classes for rating products via the simple menu
Brief Nowadays, consumers wield the power of the internet to shop for products online. A major factor in the consumer's decision-making process to purchase a product is its reliability, as determined by other consumers who have already purchased the product. In this assignment, you will individually develop classes for rating products via the simple menu interface of an online shop. Collaboration with other students Not permitted. Methodology You will develop the Product, OnlineShop and ShopApp classes. The Product class has the following private instance variables - Model name (e.g. "T-800”) - Manufacturer's name (e.g. “Cyberdyne Systems") - Retail price (as a double value) - Reliability rating, based on aggregated consumer ratings, a double value between 0.0 and 5.0 - Number of consumers who have rated the product The Product class has two constructors: 1. The first constructor takes as input the model name, manufacture name, and the retail price (in that order) 2. The second constructor takes as input the model name, manufacture name (in that order) Constructors must initialise all instance variables (using default values where necessary) The Product class has get methods to access each instance variable and a set method to set the retail price. Override the toString method to return a useful description of the Product. Reliability rating is the average of the reliability ratings by all customers who rated this product. Write the rateReliability method with a single input parameter for a customer's product reliability. The method must then increment the number of customers who rated the product and update the reliability rating using the following formula: New value of reliability rating = (Old value of reliability rating ∗ Old value of number of customers + Reliability rating by this customer) / New value of number of customers. For example, suppose that the old value of reliability was 4.5 based on the input from 100 customers. If a new customer gives a reliability rating of 1.0, then the new value of reliability would be (4.5∗100 +1.0 ) / 101 which is 4.465347. The OnlineShop has the following private instance variables - inventory, a primitive array of 5 Product objects - nProduct, an integer storing the current number of products in the inventory
The OnlineShop has a default constructor which initialises the inventory and sets nProduct to zero The OnlineShop has an add method which sets inventory[nProduct] to an input Product object and increments nProduct, as long as it does not exceed the length of inventory. The OnlineShop has a toString method which returns a string enumerating its inventory contents, using iteration to output each Product's toString on a new line. For example the toString returns a string similar to: 1. T-800, Cyberdyne Systems, $10000,4.465347 (based on 101 customer ratings) 2. Notebook, Oxford, $3.40,2.13 (based on 4 customer ratings) 3. Magic Cube, Toy Inc, $5.34,1.3 (based on 13 customer ratings) 4. Headphones, Sound Company, $99.99,2.1 (based on 30 customer ratings) 5. Coffee Thermos, Hot Cold Company, $30.99,0.0 (based on 0 customer ratings) You do not need to duplicate these products or prices etc in your assignment. It is an example. The OnlineShop class has the method getProduct which takes an integer between 1 and 5 and returns the corresponding product. E.g. 3 would return the Magic Cube. Otherwise, null is returned. The OnlineShop has no standard get or set methods. The ShopApp class has a private instance variable of type OnlineShop The static void main(String[] args) method instantiates the OnlineShop and uses its add method to populate its inventory with 5 products of your choosing. The main method implements a menu interface which repeatedly presents the following menu, asking the user to enter an option: A. Display inventory B. Rate Product C. Exit Option A prints the OnlineShop toString to the console and waits for the next user input Option B invokes the private static void rateProduct method in ShopApp which performs the following steps 1. Prints the OnlineShop toString to the console 2. Asks the user to select a product by typing a number 1 to 5 . When an invalid number is entered, e.g. 0 or −1 then an appropriate message should be presented to the user, telling them to try again. It should not generate an exception. 3. Print the product details and ask the user to enter their rating, from 0.0 to 5.0. When the user enters an invalid number, e.g. 6.0 or −1 then an appropriate message should be presented to the user, telling them to try again. Invoke rateReliability on the Product and show the user the updated Product rating via its toString method
In this method, you do not need to handle exceptions caused when the user enters a nonnumerical value. You do need to check for correct ranges of numerical values. When C is pressed ShopApp execution is terminated. All other input is gracefully ignored by the ShopApp menu interface. Marking Scheme The assignment mark is out of 100 according to the following rubric: Commenting All files must contain appropriate headers. Each method must include a brief high-level comment about the method's functionality Authenticity All work submitted must be unique and your own Submission Instructions Compress files Product.java, OnlineShop.java and ShopApp.java in an archive file. All files must contain the identification header found under Assessments on Canvas. Please ensure your submission filename matches the following: 馬 studentName_StudentID_AssignmentA.zip Upload your file to the Canvas platform. You will receive your marked assignment via Canvas. Please look over your entire assignment to make sure that it has been marked correctly. If you have any concerns, you must raise them with the lecturer. You have one week to raise any concerns regarding your mark. After that time, your mark cannot be changed.