Question: Hi guys i need help please in solving this assignment in java programming its a bit difficult the doc. is attached in here and thank

Hi guys i need help please in solving this assignment in javaprogramming its a bit difficult the doc. is attached in here andthank you. P.S: there is a deadline here is the question: Specifications:Overview: You will write two classes this week. One will represent informationHi guys i need help please in solving this assignment in java programming its a bit difficult the doc. is attached in here and thank you. P.S: there is a deadline for a product in a store (such as milk, apples, candy, orbread).

here is the question:

Specifications:

Overview: You will write two classes this week. One will represent information for a product in a store (such as milk, apples, candy, orbread). The other invoke the Product class by having an array of Products representing the store inventory.

Product

Requirements: Write a class that has the following data fields and methods:

Data Fields:

productID: integer

name: String

price: double

quantity: double

isPartitial: boolean

Constructor that takes 5 parameters:

Integer for the product ID

String for the product name

Double for the product price

Double for the product quantity

Boolean to indicate if whole numbers are required for this product (i.e. apples can be bought in partial kilograms, but milk can only be bought by whole containers)

Note: if Boolean parameter is true, quantity should be set to a whole number by rounding down the value passed for quantity

getID

Takes no parameters

Returns the product ID

getName

Takes no parameters

Returns the Product name

setName

Takes a String parameter

Changes the product name

Returns nothing

getPrice

Takes no parameters

Returns the product price

setPrice

Takes a double parameter

Checks for price to be non-negative

Changes the product price if non-negative

Displays an error message if price is negative

Returns nothing

getQuantity

Takes a double parameter

Returns the quantity

reduceQuantity

Takes a double parameter

Checks for amount requested to be non-negative

Displays an error message if negative

Checks for amount requested to be less than or equal to remaining quantity

Displays an error message if greater than amount remaining

Checks if whole numbers are required and if the amount requested is a whole number

Displays an error message if a whole number is not given but they are required

If no errors are encountered, reduces quantity by amount requested

Returns true (Boolean) if no errors are encountered, false otherwise

increaseQuantity

Takes a double parameter

Checks for amount to be added to be non-negative

Displays an error message if negative

Checks if whole numbers are required and if the amount to be added is a whole number

Displays an error message if a whole number is not given but they are required

If no errors are encountered, increases quantity by amount to be added

Returns true (Boolean) if no errors are encountered, false otherwise

Include any class variables you need to implement these methods. We will not check for these variables, so they can be named anything you choose and can be public or private.

You may also implement any other methods you think necessary, but the methods given above will be the ones that will be tested.

Store

Requirements: Write a class that has the following data fields and methods:

Data Fields:

name: String

products: array of products

Constructor that takes 2 parameters:

String for the store name

Product array for the inventory

getName

Takes no parameters

Returns the Store name

productList

Takes no parameters

Displays a heading for ID, Name, Quantity, and Price followed by the list of products

An example is shown

Returns nothing

sellProduct

Takes 2 parameters (Product ID and amount requested)

If the product is not found, displays an error message

Reduces the inventory for the product by the amount requested and displays the following (Hint: call the Product method)

Returns the cost for this product (price * quantity)

If the sale was not able to happen (Product not found, quantity has a value not allowed), returns -1

addQuantity

Takes 2 parameters (Product ID and amount to be added)

If the product is not found, displays an error message

Adds to the inventory for the product by the amount given and displays the following (Hint: call the Product method)

If the addition was not able to happen (Product not found, amount to be added has a value not allowed), returns false

Returns true otherwise

discount

Takes 2 parameters (Product ID and percentage to be discounted)

If the product is not found, displays an error message

Changes the price of product to the old price * (1 discount percentage) and displays the following

(25% discount, 0.25 was entered)

Returns nothing

Include any class variables you need to implement these methods. We will not check for these variables, so they can be named anything you choose and can be public or private.

You may also implement any other methods you think necessary, but the methods given above will be the ones that will be tested.

words Qx English (United States) Specifications: overview: You will write two classes this week. One will represent information for a product in a store (such as milk, apples, candy, or...bread). The other invoke the Product class by having an array of Products representing the store inventory. Product Requirements: Write a class that has the following data fields and methods: Data Fields o productID: integer o name: String o price: double o quantity: double o is Partitial: boolean Constructor that takes 5 parameters: o Integer for the product ID o String for the product name o Double for the product price o Double for the product quantity o Boolean to indicate if whole numbers are required for this product (i.e. apples can be bought in partial kilograms, but milk can only be bought by whole containers) o Note: if Boolean parameter is true, quantity should be set to a whole number by rounding down the value passed for quantity etID o T no parameters akes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!