Cosc2531 programming fundamentals assignment - playstore


Programming Fundamentals Assignment - PlayStore: Mobile Applications Management system

Objective - The main objective of this assignment is to familiarize students with object oriented design, programming, testing, and refactoring. Object oriented programming helps to solve complex problems by coming up with a number of domain classes and associations. However, identifying meaningful classes and interactions requires a fair amount of design experience. Such experience cannot be gained by classroom-based teaching alone but must be gained through project experience. The different stages of this assignment are designed to gradually introduce different concepts such as inheritance, abstract classes, method overloading, method overriding, and polymorphism.

Assignment overview - A playStore is a standalone digital marketplace that allows users to browse and download mobile phone applications. The playStore also serves as a digital multimedia store offering music, magazines, books, movies, and television programs. Applications and multimedia items in playStore are either free or can be bought for a price.

Assessment tasks - 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 playStore.

Where the specification is subject to interpretation, you may make any reasonable assumptions but you are required to justify those using comments. There is a sample main method in PlayStore.java file along with its expected outputs are provided in the Canvas course shell for testing. You may write your own main method for testing. If you want to demonstrate with your own written main method, make sure you include checking all the functionalities with proper comments. All attributes and methods (except 'main' method) are non-static.

Section 1: The classes and their attributes - write the required classes

Class A - The mobile phone apps and the multimedia items are 'Content' of the playStore. Each 'Content' (either application or multimedia) is associated with the following information: an ID, application name, number of downloads, price, and review. A content type of object cannot be created. Review is an array of 'Comment' type of objects (See Class B for details).

Class B - Write a 'Comment' class that has the following data: a 'User' type of object, which is the user who wrote the comment (See Task D for details on 'User'), a string for the comment, and an array of 'Comment' type of objects as the reply of the comment. A 'Comment' type of object can be initialized as - Comment cmnt = new Comment(u1, "This is a fantastic game!");

Here, 'u1' is an 'User' type of object, and "This is a fantastic game!" is the string as comment. Initially, the reply is empty.

Class C - Write an 'OS' class that contains the type of mobile operating system (e.g., Android or iOS), and the version number. The type of operating system is a string. For simplicity, assume the version number is an integer. An 'OS' type of object can be initialized as - OS os1 = new OS("Android", 4);

Class D - Write a 'User' class, where each user has an ID, a name, a phone number, a balance, and an 'OS' type of object. Assume that the phone number is a string, as that will allow you to store a zero at the beginning. A 'User' can be initialized as - User u1 = new User("u1", "John Doe", "0400000000", 20, os1); or as - User u1 = new User("u1", "John Doe", "0400000000", os1);

If the User object is initialized in the second way, the balance of that user is zero.

Class E - You have been provided a 'PlayStore' class in the Canvas that contains the main method. The 'PlayStore' class has a collection of 'Content' and a list of 'User' objects (you are encouraged to use Java collections like ArrayList and Hashtable). Note that each content can be uniquely identified based on content ID (Please see the use of java collections Hashtable for details on this requirement).

An instance of the PlayStore class, called 'Admin' is initialized from the main method. For this assignment, only the admin will carry out all operations on behalf of the users.

Section 2: Functionalities of the classes

Users' functionalities

1. Write a method of the User class "becomePremium". A user can become a Premium user for a cost of $100. A premium user gets 20% discount on the price of each of the contents she buys after becoming premium. The balance of a user cannot become negative.

Exceptions must be thrown when an attempt is made to become premium without having sufficient balance. The exception thrown must indicate the cause of error, show an appropriate error message, and allowing the caller to proceed to the next statements of the program.

2. Write a method of the User class "buyContent", 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. You need to consider whether the user is a premium user or not in this step. The number of downloads of the content also increase by one when a user buys it.

a. Exceptions must be thrown when an attempt is made to buy a content without having sufficient balance. The exception thrown must indicate the cause of error, show an appropriate error message, and allowing the caller to proceed to the next statements of the program.

b. If the content of "buyContent" method is a "Game" type of object, you need to first check the compatibility of the OS of the user, and the minimum OS requirement of the game. If the operating system of the user is "Android", and the OS requirement of the game is "iOS" (i.e., the operating systems are not the same), an appropriate exception must be thrown. If the version number of the user's OS is less than the version number of the required OS of the game, an appropriate exception must be thrown. The thrown exceptions must indicate the cause of error, show an appropriate error message, and allowing the caller to proceed to the next statements of the program.

As an example, let the OS of the game is ("Android", 5) and the OS of the user is ("Android", 4). Although the operating systems are the same, the user's version number is less than the minimum required version number of the game, so the user cannot buy this game.

3. A user may buy multiple contents. Write a method "AllContentsBought" in the User class to show the list of names of all the contents that the user bought. You may add additional attributes in the User class if necessary.

Contents' and Comments' functionalities

4. Write a method of the "Content" class, where a review (which is a comment type of object) from a user can be added to a content type of object.

5. Write a method of the Comment class to add a reply (which is a comment type of object) to a specific comment.

As an example of adding reviews and replies from the main method, see the following code snippet (which can also be found in the main method provided in the Canvas)

Comment cmnt = new Comment(u1, "This is a fantastic game!");

g1.addReviews(cmnt); //g1 is a Game type of object, see description of Class A.1

Comment r1 = new Comment(u2, "I never liked this game!");

cmnt.addReply(r1);

Comment r2 = new Comment(u1, "Really??");

r1.addReply(r2);

Comment cmnt2 = new Comment(u3, "The game crashes frequently.");

g1.addReviews(cmnt2);

6. Write a method "ShowReview" in the "Contents" class to show all the reviews of a particular content object. If a review has replies to its comments, show them as well. Show the replies of the comments with an indentation at the beginning of each reply. In case you are unable to show them with proper indentations, you will receive partial marks for showing the comments. Sample output is shown bellow, (also provided in the Canvas shell)

John Doe (u1): This is a fantastic game!

Jane Joe (u2): I never liked this game!

John Doe (u1): Really??

David Roe (u3): The game crashes frequently.

PlayStores' and Admin's functionalities

7. Write a method "showAllContents" of the "PlayStore" class to show a list of all available contents. Also write a method for each type of contents to show the list of contents of that type (e.g., show all games, show all books, show all magazines). Do you need to write a method for each type, or you can use the same method for this task?

Also, you need to provide methods in the PlayStore class to add "Content" objects and "User" objects. You don't need to handle deletion of objects.

8. Write a method of the "PlayStore" class to show the list of all Reading type of objects with a given genre. The parameter of this method should be a String, representing the genre (for example, "Novel").

Other requirements:

Properly use the access modifiers of the attributes and the methods of the classes. Think if you require them to be private/public/protected/with no access modifier. If an attribute is private, do you need to write an accesor method to get the value of that attribute (e.g., getID() for 'Content' class)?

Attachment:- Assignment Files.rar

Solution Preview :

Prepared by a verified Expert
Dissertation: Cosc2531 programming fundamentals assignment - playstore
Reference No:- TGS02784037

Now Priced at $60 (50% Discount)

Recommended (95%)

Rated (4.7/5)