CS 1120 Fall 2019 LA4 Polymorphism & Interfaces 1 Lab Assignment 4 Stores Application DUE DATE Lab Time Due Date Wednesday Labs 10/30/2019 11:59 PM Objectives • Reviewing Inheritance • Reviewing...

i


CS 1120 Fall 2019 LA4 Polymorphism & Interfaces 1 Lab Assignment 4 Stores Application DUE DATE Lab Time Due Date Wednesday Labs 10/30/2019 11:59 PM Objectives • Reviewing Inheritance • Reviewing Polymorphism • Reviewing Interfaces Problem Specification Develop a Java application which implements an application for a store chain that has three types of stores which are Book, Music, and Movie stores. The following UML class diagram shows how your application should be created (it shows the relationships between the various classes and interfaces). Sasbit Koirala Sasbit Koirala CS 1120 Fall 2019 LA4 Polymorphism & Interfaces 2 Design Requirements Your application should have an Item abstract class which should be extended by the Book and Multimedia classes. Item class has abstract priceAfterTax method, you need to implement this method in derived classes. Multimedia class is a superclass for Music and Movie classes. Your project should also include the IPromotion interface, which should be implemented by Book and Movie classes. Also, your application should have the Lookup class (which is provided in part in this document). Lookup class works as the datastore: it contains all the various items available - books, movies, music items - as well as the list of users. In your main class you should initiate a lookup object in the main method. You also need to include a User class which has the fields and the methods shown for that class in the class diagram. User class has a library of items; once a user downloads or purchases any item, you should add this item to that user’s library. If the user just plays music or watches a movie you should not add this item to the user’s library. Hints: 1- Most of your classes should override the toString method. So, to print store items you should use the toString method. 2- To calculate promotionValue (i.e. price after promotionRate is applied), you need to implement this equation (price = price – price*promotionRate). a. PromotionRate for book items is 0.8, and for movie items is 0.5. There is no promotionRate for music items. 3- To calculate total price including taxes, you need to implement this equation (price = price + price*taxRate). a. TaxRate for book items is 0.2, taxRate for multimedia items is 0.25. The interface IPromotion and part of the code for class Lookup are provided below. public interface IPromotion { /** * This method is called by the getPrice methods for Book * and Movie classes. * @return promotion value which is 0.8 for Book item * and 0.5 for movie item */ public double salesPromotion(); } public class Lookup{ public User[] userList; public Item[] storeItemList; public Lookup() { userList = createUsers(); storeItemList = loadItems(); } Sasbit Koirala CS 1120 Fall 2019 LA4 Polymorphism & Interfaces 3 /** * * @param userName * @param password * @return Return the user object it it exist */ public User checkLoginAuth(String userName, String password) { } public User[] getUserList() { } public void setUserList(User[] userList) { } public Item[] getStoreItemList() { } public void setStoreItemList(Item[] mStoreItemList) { } /** * This method adds two users to the user list, * "You should not change these users, but you * can add new users */ public User[] createUsers() { User[] list = new User[2]; list[0] = new User(1, "john", "123"); list[1] = new User(2, "Ira", "321"); return list; } /** * This method load data to the item list, this list has all the * items in your application "You should not change these data * but you can add new items". * */ public Item[] loadItems() { Item[] itemList = new Item[5]; String[] languages = new String[2]; languages[0] = "English"; languages[1] = "Arabic"; itemList[0] = new Book(1, "Engineering Analysis with SOLIDWORKS Simulation 2017", "SDC Publications", "\tEngineering Analysis with SOLIDWORKS Simulation 2017" + " \n\tgoes beyond the standard software manual." + " \n\tIts unique approach concurrently introduces you to the SOLIDWORKS" Sasbit Koirala CS 1120 Fall 2019 LA4 Polymorphism & Interfaces 4 + " \n\tSimulation 2017 software and the fundamentals of Finite Element Analysis" + " \n\t(FEA) through hands-on exercises. A number of projects are presented" + " \n\tusing commonly used parts to illustrate the analysis features of " + "\n\tSOLIDWORKS Simulation. Each chapter is designed to build on the skills, " + "\n\texperiences and understanding gained from the previous chapters.", false, 10, 578, "Paul Kurowski", "9781630570767", languages); itemList[1] = new Book(2, "SQL Queries for Mere Mortals", "Addison-Wesley Professional", "\tSQL Queries for Mere Mortals ® has earned worldwide praise " + "\n\tas the clearest, simplest tutorial on writing effective SQL queries." + "\n\tThe authors have updated this hands-on classic to reflect new " + "\n\tSQL standards and database applications and teach valuable new techniques." + "\n\tStep by step, John L. Viescas and Michael J. Hernandez guide you through " + "\n\tcreating reliable queries for virtually any modern SQL-based database. " + "\n\tThey demystify all aspects of SQL query writing, from simple data selection" + "\n\tand filtering to joining multiple tables and modifying sets of data.", true, 0, 792, "John L. ViescasMichael J. Hernandez", "9780133824841", languages); itemList[2] = new Movie(101, "Smurfs: The Lost Village", "Dupuis", "\tFully animated with new characters looking like the original" + "\n\tPeyo's animation. This film will answer all of the questions " + "\n\tof the Smurfs such as \"Why do the Smurfs live in " + "\n\tsara mushrooms?\" and \"Why don't the Smurfs wear shirts?\"", false, 20, 89, "English", "Animation"); itemList[3] = new Movie(101, "Black Panther", "Ryan Coogler", "\tAfter the death of his father, the king of Wakanda," + "\n\tyoung T’Challa returns home to the isolated high- tech " + "\n\tAfrican nation to succeed to the throne and take his rightful" + "\n\tplace as king. But when a powerful enemy reappears," Sasbit Koirala CS 1120 Fall 2019 LA4 Polymorphism & Interfaces 5 + "\n\tT’Challa’s mettle as king – and Black Panther – is tested when" + "\n\the’s drawn into a formidable conflict that puts the fate of" + "\n\tWakanda and the entire world at risk.", false, 20, 89, "English", "Action & Adventure"); itemList[4] = new Music(201, "Le rossignol", "Modest Mussorgsky", "\r1-The Nutcracker (Suite), Op.71a: 3. Waltz of the Flowers" + "\r\n2- The Nutcracker (Suite), Op.71a: 2b. Dance of the Sugar Plum Fairy"+ "\r\n3- Prelude in C Major, Op. 12, No. 7", false, 2, 4, "MP3", "Russian Album"); return itemList; } /** * Print Movie list from storeItemList */ public void printMovieList() { } /** * Print Books list from storeItemList */ public void printBookList() { } /** * Print Music list from storeItemList */ public void printMusicList() { } /** * This method searches for the item by its key * and then return the item object if the item exist * else return null */ public Item getItemById(int key) { } } Pseudocode Write detailed pseudocode for all the methods in your classes. Sasbit Koirala CS 1120 Fall 2019 LA4 Polymorphism & Interfaces 6 Implementation Phase Using the pseudocode developed, write the Java code for your assignment. This is
Oct 30, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here