Simulating interaction with the shop

Assignment Help JAVA Programming
Reference no: EM132529140

Assessment details

MyShop is an online shop which allows users to download mobile applications (APPs) and publications like e-books and digital magazines. Applications and publication items in the MyShop are either free or can be bought for a price.

The program you create will allow the creation of a shop, filling it with products, creating users and simulating their interaction with the shop (requiring products, adding comments etc).

Your program should consist of multiple class files where you can demonstrate your knowledge of inheritance, polymorphism, method overriding, abstract classes, etc. You need to write classes, add methods and variables to complete the following tasks performed by the admin of the MyShop.

There are two sample/starter classes (MyShopMain.java and MyShop.java) provided.

The tasks in this assignments have been divided into different levels. You must complete all prior levels before moving on to a higher level.
You must specify the highest level that you have completed at the top of MyShopMain.java

Part 1: PASS Level

You may need to define methods wherever appropriate to support these classes.

Class MyShop
The MyShop class have two attributes: a list of Content and a list of User objects. Note that each content has a unique ID. An instance of the MyShop class named shop is created in the main method of MyShopMain. The interaction with this shop is simulated within the main method (see the MyShopMain.java class).

Write a method showContent in the MyShop class to show a list of all available contents.

Class Content
Mobile apps and publication items are Content of the MyShop. Each Content (either application or publication) is associated with the following information: an ID, name, number of downloads, price. Class Content cannot and should not be instantiated.

Class Application
Application objects contain information such as ID, name, number of downloads and price. In addition, an Application object has an OS (operating system) type that presents the minimum operating system requirement. An Application object can be initialized as

Application game1 = new Application("g1", "Fruit Ninja", 4.7, "androidV4");
In the above example the price of the app is $4.7 dollar, "androidV4" is the OS requirement. Initially the number of downloads is zero.
If no price is provided, the application is then free.

Application app1 = new Application("app1", "Calendar", "androidV3");

Class Publication
Another type of Content is Publication. In addition to the data that the Content class has, a Publication object also has: publisher and number of pages.

Class Book
Book is one type of Publication. It has additional data: publisher, number of pages and author name. Notes, it is possible that one book have multiple authors.

A Book object can be initialized as
String[] authors = {"L. Tolstoy"};
Book b1 = new Book ("b1", "War and Peace", 12.55, "The Russian Messenger", 1225, authors);
"War and Peace" is the name of the book; 12.55 is the price; "The Russian Messenger" is the publisher. The book has 1225 pages and is of course authored by "L. Tolstoy".

Class Magazine
Another type of Publication is Magazine, which has an additional data: volume. A magazine does not contain any author's name. A Magazine object can be initialized as

Magazine m1 = new Magazine("m1", "Forbes", 8.99, "Forbes Media", 50, 202004);

The name of the magazine here is "Forbes", selling for $8.99. The publisher is "Forbes Media". It has 50 pages, and the current volume is 202004. You can assume the volume is always an integer showing the year and the month.

At this level, your program should be able to show all the contents in the shop including all the applications, books and magazines been added to the shop.

New contents can be directly added in MyShopMain.java. It also allows keyboard input to enter new contents. You are free to design the input menu. Note input validation is required.

Part 2: CREDIT Level --- You must ONLY attempt this level after you complete the PASS level

Class User

The User class has an ID, a username. NOTE, username can be changed by changeName() method.

Class Customer

Customer is a type of user. Each customer has a phone number and available fund in the account. By default, a new user will start with 50 in balance. A Customer can be initialized as:

Customer c1 = new Customer("u1", "coolguy", "0412000", 200);
// Mary has a balance of 50
User u2 = new User("u2", "neversaynever", "0433191");
// c2 has a balance of 50
Customer c2 = new Customer("u2", "neversaynever", "0433191");

Class Admin

Admin is a special type of user. Each admin has a password and a level. The level is an integer indicating the level of his/her admin privilege.

Admin a2 = new Admin("a2", "Adele", "kitty123", 3);

At this level, your program should be able to show all the users in the shop including all the customers and admins. New users can be added in MyShopMain.java.

Part 3: DI Level --- You must ONLY attempt this level after you complete the CREDIT level

A this level, each content item, either application or publication, can be reviewed by customers. Review is a collection of Comment object. One content may have multiple comments as its review.

Class Comment
A Comment class keeps the following data: a Customer, which is customer who wrote the comment and a string for the comment. A Comment object can be initialized as

Comment comment1 = new Comment(c1, "This is a fantastic game!");

A Comment class may be initialised with an integer between 0 to 5, which is the rating from the customer.

Comment comment2 = new Comment(c2, 5);

A mix is also possible, e.g.

Comment comment3 = new Comment(c3, 3, "This is an average game!"); Comment comment4 = new Comment(c4, "I quite like this game!", 4);
Your program should be able to show all the comments for one content. It can also show every comment in the shop as well (all comments for all contents). New comments can be added in MyShopMain.java.

In addition, customers can buy content through method download, where the parameter is a Content type of object. When a user buys any content, the price of that content needs to be deducted from the balance of that user. Do necessary checks before the deduction. The number of downloads of the content should be updated as well after the purchase.

A user may buy multiple content. Write a method showDownloads in the User class to show the list of names of all the contents that the user has bought.

Your program can show the number of downloads for one content. It can also show the number of downloads for all contents in the shop as well. You are free to design how that can be shown.

Part 4: HD Level --- You must ONLY attempt this level after you complete the DI level

Premium customer

With the method becomePremium(), a customer can be upgraded to a Premium customer for a cost of $100. A premium customer gets 20% discount on each purchase of contents after becoming premium. Be careful, this upgrade is NOT free.

You can assume this upgrade cannot be undone, meaning there is no downgrade and refund.

Bulk download

At this level, customers can download in bulk, e.g. download(list), there are multiple items in list. If the bulk download is not successful, e.g. short of fund, then nothing will be added.

Admin functions

An admin can login in and reset the price for and item, e.g.

b1.setPrice(a2.login(), 14.25);

The setPrice method takes the return value of method login() as one of its input parameter. If login is successful, then the price of b1 will be set to 14.25. Otherwise unchanged.

The login() method simply asks for keyboard input and checks whether the input is the same as the password stored in the admin object. That is a2 in the above example.
If the admin's level is above 5, then the admin can adjust prices in bulk for all contents in the shop, e.g. a bulk price reduction of 10% as shown below. This task would not be successful if the admin's privilege level is 5 or below.

shop.setPrice(a1.login(), a1.getLevel(), -0.10);

Part 5: Input and output

Your program should hard code a list of objects including content objects, user objects and comment objects etc. for testing purpose. See the skeleton sample code. (During marking, we may replace these objects with our own to test your program).

You program should have a simple menu to allow aforementioned tasks up to the level you are attempting, for example: showing all contents; downloading one content for one user; showing all downloaded content of a user; upgrading a member to premium account; showing all comments of all contents etc.

Attachment:- java assignment.rar

Reference no: EM132529140

Questions Cloud

Calculate the probability in a given year that area : A certain area of eastern United States is, on average, hit by 6 hurricanes a year.
Function to find the median of the given data : A program in R language for user defined function to find the median of the given data. Take appropriate data of your choice.
Which of the statements is true of hannibal inc : The company calculates a net present value for the new refrigerator of $6,000. Based on this information, which of the following statements is true?
Determining the number of students height : a. The height of the students in a certain class is following normal distribution with mean Height as 165 cm and standard deviation of 25 cm. There are 60 stude
Simulating interaction with the shop : Demonstrate your knowledge of inheritance, polymorphism, method overriding, abstract classes, etc. You need to write classes, add methods and variables
Fit a linear regression model to the data : a. Fit a linear regression model to the data by OLS and interpret the results.
Determine what is the materials quantity variance for month : What is the materials quantity variance for the month? The data pertain to operations concerning the product for the last month.
Dependent variable and machine-hours : Salter Manufacturing Company produces inventory in a highly automated assembly plant in Fall River, Massachusetts. The automated system is in its first year
Reflections discussion-business planning : Prior to beginning this discussion thread, read Business planning for 2018, and how to cash in on the New Year and Six Tips for Planning a great 2018.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program in java to repeat hello world

Write a program in Java to repeat Hello World 10 times. What is JVM (Java Virtual Machine)

  Expain what is runtime polymorphism

Expain What is runtime polymorphism in java programming?

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  What are the three primary building blocks of java program

What are the three primary building blocks of a Java program structure? Explain how each primary component is used in a Java program by providing one instance

  On which classes does class integer in java library depend

On which classes does the class Integer in the Java standard library depend? On which classes does the class java.awt.Rectangle in standard library depend?

  Cascading style sheet to a website

Compare and contrast the process of adding JavaScript and a Cascading Style Sheet to a Website. Determine if they can be used simultaneously in a page.

  Perform the analysis and collect the user requirements

1. After we perform the analysis and collect the user requirements, the process of identifying classes begins. How do we identify classes? How do we decide the responsibilities of each class? Shall a class take more than one responsibility?

  Implement a class student

Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply a suitable constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).

  Write a program which randomly chooses an integer

Write a program which randomly chooses an integer from 1 to 100. The program should then tell the user.The program should then ask the user to complete the puzzle such that each row and each column consists of the letters

  Create a webpage that prints

Write a programme to create a webpage that prints the name of the STUDENT database in Wide Latin font and set the subtitle with description of the STUDENT to the screen. Set the page layout to the webpage.

  Implement the classes and interfaces

You decide it's time to break into the niche market of space combat simulators. The basic idea behind your sim is that you control a spaceship that can fire dif

  Implement security so that all users can view the informatio

Implement security so that all users can view the information about the projects, but only authenticated users

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd