Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java code 1. Create a new Java Project within the same workspace named Store. 2. Create a package named com.javaoo.store. Exercise 1: Creating the Inventory

java code image text in transcribed
image text in transcribed
image text in transcribed
1. Create a new Java Project within the same workspace named Store. 2. Create a package named com.javaoo.store. Exercise 1: Creating the Inventory System Classes 3. Create each of the following classes in the com.javaoo.store package: a. Item b. Artist c. Book which is a sub-class of Item d. CD which is a sub-class of Item e. ClassicalCD which is a sub-class of Item Exercise 2: Adding Attributes and Methods 4. For each of the inventory system classes, add the necessary attributes and methods as specified below. 5. Item: a. Declare the following private attributes i. title which is a string ii. price which is a double iii. quantity which is an int b. Create getter and setter methods for each of the attributes. In most IDEs, this can be done quite easily by right-clicking in the editor and choosing Source > Generate Getters and Setters. If you have any difficulty, please ask your instructor. Artist: a. Declare the following private attributes. i. name which is a String ii. memberNames which is an array of 20 Strings iii. memberInstruments[] which is an array of 20 Strings b. For now, create a getter and setter method for the name attribute only Book: a. Declare the following private attributes. i. author which is a String ii. publisher which is a String iii. category which is a String b. Create getter and setter methods for each of the attributes. Individual 3. CD a. Declare the following private attributes. i. artist which is an object of type Artist ii. releaseDate which is an object of type Date b. You will need to import the java.util.Date class c. Create getter and setter methods for each of the attributes. 9. ClassicalCD: a. Declare the following private attributes. i. composer which is a String ii. performers [] which is an array of 5 Strings iii. recording Location which is a string iv. release Date which is an object of type Date b. You will need to import the java.util.Date class C. Create getter and setter methods for each of the attributes except for performers []. 10. At this point, all of your code should compile. We haven't created a main() method yet so we can't execute any of it but ensure that you do not have any compilation errors before continuing. Exercise 3: Working with Array Attributes 11. For the performers [] attribute of the ClassicalCD class we are going to create a method called addPerformer (String performer). This method will need to know how many elements in the array are already being used. The length attribute won't help us - it just tells us how many slots there are for holding data. So: a. Create a private attribute named performerCount which is of type int and initialize it to zero. b. Create the addPerformer() method. c. Within the body of addPerformer() test to make sure there is still room in the performers [] array. Use performers.length and performerCount to manage this test. d. If there is no room left in the array, display a message warning the user. e. If there are available slots in the array, add the performer name. f. Ensure that you increment performerCount ! 12. We also want a method to display all of the performers for a ClassicalCD. Write a method called showPerformers() which loops through the elements of the array and prints them to the console. USE THE performerCount attribute! Do not print out empty array slots

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions

Question

CFD is highly risky. Do you agree? Give reasons for your answer.

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago