Starting from:
$35

$29

Lab Assignment 4 Stores Application Solution

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).

































































































1

CS 1120 LA4 Polymorphism & Interfaces







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).




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();




}




2

CS 1120 LA4 Polymorphism & Interfaces










/**




*

@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"




3

CS 1120 LA4 Polymorphism & Interfaces







" \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,"







4

CS 1120 LA4 Polymorphism & Interfaces







+ "\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.
















5

CS 1120 LA4 Polymorphism & Interfaces







Implementation Phase




Using the pseudocode developed, write the Java code for your assignment. This is a one-week assignment.




You need to implement all the methods and fields in the class diagram you should not create new methods.




Add constructors to the superclass and each subclass, using the super keyword in the subclasses to utilize the superclass’s constructor.




Testing Phase




An example output to be followed exactly is provided below.




Example Output:




Enter your UserName:

john




Enter your Password:

111




Incorrect username or password




Enter your UserName:

john




Enter your Password:

123




Login Successful!




Store List Menu:

1- Book Store

2- Music Store

3- Movie Store




4- My Library

0- Quit




Select one of these options:




1

**************Book Store**************




Item Key: 1




Engineering Analysis with SOLIDWORKS Simulation 2017 Publisher: SDC Publications Description:




Engineering Analysis with SOLIDWORKS Simulation 2017 goes beyond the standard software manual.




Its unique approach concurrently introduces you to the SOLIDWORKS Simulation 2017 software and the fundamentals of Finite Element Analysis (FEA) through hands-on exercises. A number of projects are presented using commonly used parts to illustrate the analysis features of SOLIDWORKS Simulation. Each chapter is designed to build on the skills, experiences and understanding gained from the previous chapters.

Price: $2.00




ISBN: 9781630570767

Pages: 578




Writer Name: Paul Kurowski

Languages: English, Arabic,




6

CS 1120 LA4 Polymorphism & Interfaces







--------------------------




Item Key: 2

SQL Queries for Mere Mortals




Publisher: Addison-Wesley Professional

Description:




SQL Queries for Mere Mortals ® has earned worldwide praise




as the clearest, simplest tutorial on writing effective SQL queries.

The authors have updated this hands-on classic to reflect new




SQL standards and database applications and teach valuable new techniques. Step by step, John L. Viescas and Michael J. Hernandez guide you through creating reliable queries for virtually any modern SQL-based database. They demystify all aspects of SQL query writing, from simple data selection and filtering to joining multiple tables and modifying sets of data.

Price: Free

ISBN: 9780133824841




Pages: 792

Writer Name: John L. ViescasMichael J. Hernandez




Languages: English, Arabic,

--------------------------




***************************************




1- Download book

2- Return to Stores list menu




Select one of these options:

1




Enter Book Key:




5

This key is not existing




Enter Book Key:

1




This item is not free, the total cost after taxes = $2.40 // i.e. price plus tax Enter the price to continue or 0 to exit




2.4




Download Successfully Completed

1- Download book




2- Return to Stores list menu

Select one of these options:




1

Enter Book Key:




2




Download Successfully Completed

1- Download book




2- Return to Stores list menu

Select one of these options:




2

Store List Menu:




1- Book Store




2- Music Store

3- Movie Store




4- My Library

0- Quit




Select one of these options:

3




**************Movie Store**************







7

CS 1120 LA4 Polymorphism & Interfaces







Item Key: 101

Smurfs: The Lost Village

Publisher: Dupuis

Description:




Fully animated with new characters looking like the original Peyo's animation. This film will answer all of the questions of the Smurfs such as "Why do the Smurfs live in




sara mushrooms?" and "Why don't the Smurfs wear shirts?"

Run time: 89.0 minutes




Price: $10.00

Category: Animation




AudioLanguage: English

--------------------------




Item Key: 101

Black Panther

Publisher: Ryan Coogler

Description:




After the death of his father, the king of Wakanda, young T’Challa returns home to the isolated high-tech African nation to succeed to the throne and take his rightful place as king. But when a powerful enemy reappears, T’Challa’s mettle as king – and Black Panther – is tested when he’s drawn into a formidable conflict that puts the fate of Wakanda and the entire world at risk.




Run time: 89.0 minutes




Price: $10.00

Category: Action & Adventure




AudioLanguage: English

--------------------------

***************************************

1- Play or Purchase Movie




0- Return to Store list menu




Select one of these options:

1




Enter Movie Key:

34




This key is not existing

Enter Movie Key:




101




This item is not free, the total cost after taxes = $11.50 Enter the price to continue or 0 to exit




11.5

Playing!




1- Play or Purchase Movie

0- Return to Store list menu




Select one of these options:




0

Store List Menu:




1- Book Store

2- Music Store




3- Movie Store

4- My Library




0- Quit




Select one of these options:




8

CS 1120 LA4 Polymorphism & Interfaces







4

*************User Library*************

Item Key: 1




Engineering Analysis with SOLIDWORKS Simulation 2017 Publisher: SDC Publications Description:




Engineering Analysis with SOLIDWORKS Simulation 2017 goes beyond the standard software manual.




Its unique approach concurrently introduces you to the SOLIDWORKS Simulation 2017 software and the fundamentals of Finite Element Analysis (FEA) through hands-on exercises. A number of projects are presented using commonly used parts to illustrate the analysis features of SOLIDWORKS Simulation. Each chapter is designed to build on the skills, experiences and understanding gained from the previous chapters.

Price: $2.00

ISBN: 9781630570767




Pages: 578

Writer Name: Paul Kurowski




Languages: English, Arabic,

************************************




Item Key: 2




SQL Queries for Mere Mortals

Publisher: Addison-Wesley Professional




Description:

SQL Queries for Mere Mortals ® has earned worldwide praise




as the clearest, simplest tutorial on writing effective SQL queries.




The authors have updated this hands-on classic to reflect new




SQL standards and database applications and teach valuable new techniques. Step by step, John L. Viescas and Michael J. Hernandez guide you through creating reliable queries for virtually any modern SQL-based database.




They demystify all aspects of SQL query writing, from simple data selection and filtering to joining multiple tables and modifying sets of data.




Price: Free




ISBN: 9780133824841

Pages: 792




Writer Name: John L. ViescasMichael J. Hernandez

Languages: English, Arabic,




************************************

Item Key: 101




Smurfs: The Lost Village




Publisher: Dupuis

Description:




Fully animated with new characters looking like the original Peyo's animation. This film will answer all of the questions of the Smurfs such as "Why do the Smurfs live in




sara mushrooms?" and "Why don't the Smurfs wear shirts?"




Run time: 89.0 minutes




Price: $10.00

Category: Animation




AudioLanguage: English




Store List Menu:

1- Book Store




2- Music Store




3- Movie Store




9

CS 1120

LA4

Polymorphism & Interfaces






4- My Library

0- Quit




Select one of these options:

0



Additional Requirements




A proper design (with detailed pseudocode) and proper testing are essential.




Note: Correct pseudocode development will be worth 40% of the total LA grade.




You will need to generate Javadoc for your project. Follow the steps shown in class (a copy of these steps can be found on the Content page in Elearning, or can otherwise be provided to you by your Lab instructor). If you follow the steps accurately, a “doc” folder (for Javadoc) should be created in your project.




Coding Standards




You must adhere to all conventions in the CS 1120 Java coding standards (available on Elearning for your Lab). This includes the use of white spaces and indentations for readability, and the use of comments to explain the meaning of various methods and attributes. Be sure to follow the conventions also for naming classes, variables, method parameters and methods.




Assignment Submission




Generate a .zip file that contains all your files including: o Program files



o Any input or output files

o Detailed pseudocode for your program




You can refer to the link provided for instructions on how to export your project to a .zip file (“How




to submit a programming assignment” ).




Submit the .zip file to the appropriate folder on Elearning.



NOTE: The eLearning folder for LA submission will remain open beyond the due date but will indicate how many days late an assignment was submitted where applicable. The dropbox will be inaccessible seven days after the due date by which time no more credit can be received for the assignment.




The penalty for late submissions as stated in the course syllabus will be applied in grading any assignment submitted late.




























10

More products