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