Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java please . . . This programming assignment is intended to demonstrate your knowledge of the following: Declare a new class and instantiate an object

Java please image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
. . . This programming assignment is intended to demonstrate your knowledge of the following: Declare a new class and instantiate an object Write instance methods that return a value Write instance methods that take arguments Creating an Inventory Project (100 points) Create an inventory program that can be used for a range of different products of school supplies (pencils, erasers, markers, notebooks, etc.). Topic(s): Creating classes/objects Instance variables/fields Constructors Methods (getters/accessors, setters/mutators) Overloading .toString() method You will design an inventory system will store these specific products. This table gives you an understanding of the type of data that you will want to store for the attributes of each product. A. The following table lists 6 example products that you want to store in your system. Attribute Sample Data Name of the product (the value that will Pencil identify the product in your system) Pen Marker Colored Pencil Eraser Notebook Price (this value holds the price that each 9.99 item will be sold for). 8.99 7.75 9.5 4.00 6.75 25 Quantity of units in stock Ithis value will Quantity of units in stock (this value will store how many of each product item is currently in stock). Item number (used to uniquely identify the product in your system). 25 75 200 500 150 400 1 2 3 4 5 6 B. The following table gives you an understanding of the type of data that you will want to store tor the attributes of each product. Attribute Sample Data Data Type Name of the product. Pencil String Price. 9.99 Double Quantity of units in stock. 25 Integer Item number. 1 Integer 1. Open Eclipse and create a project named Project6. 2. Create a class called Product. 3. Add the following private instance fields (variables) by using the data types you identified in point B: a) item number b) the name of the product c) the quantity of units in stock d) the price of each unit 4. Add a comment above the instance field declarations that states: // Instance field declarations 5. Create two constructors: a) A default constructor without parameters that will allow the compiler to initialize the fields to their default values. Add a comment above your constructor that explains the purpose of the constructor b) Overload the default constructor by creating a constructor with parameters for all four of the class' instance fields so that they can be initialized values from the driver class. The parameters should be named: number, name, aty, price. Example: this.name = name; 6. Write getter/accessor and setter/mutator methods for each of the four instance variables. Add comments above them to explain their purpose. 7. Write the toString() method to show a description of each Product object that includes the instance field values in the following format: Item Number : 1 Name : Pencil Quantity in stock 25 7. Write the toString() method to show a description of each Product object that includes the insta field values in the following format: Item Number :1 Name : Pencil Quantity in stock : 25 Price : 9.99 8. Create a Java main class called ProductTester. 9. Create and initialize six Product objects based on the list in point A. a. Two of the Products should be created using the default constructor. b. The other four should be created by providing values for the arguments that match the parameters of the constructor. 10. Using the ProductTester class, display the details of each product to the console. 11. Save your project. Here is a sample run: Item Number: 0 Name : null Quantity in stock: 0 Price : 0.0 Item Number: 0 Name : null Quantity in stock: 0 Price : 0.0 Item Number: 3 Name : Marker Quantity in stock: 200 Price : 7.75 Item Number: 4 Name : Colored Pencil Quantity in stock: 500 Price : 9.5 Item Number: 5 Name : Eraser Quantity in stock: 150 Price : 4.0 Item Number: 6 Name : Notebook Quantity in stock: 400 Price : 6.75

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

5. How do instructional objectives help learning to occur?

Answered: 1 week ago

Question

4. Help trainees set challenging mastery or learning goals.

Answered: 1 week ago