0% found this document useful (0 votes)
38 views

Create Getter and Setter Method, Override Tostring With: String - Format ("%-5S %-20S %-10S %-10S %-5S",.... )

The document describes requirements for a Fair Shop application to manage stock of consumable goods. It needs to track each item's unique ID, name, purchase and sales prices, and grade. Sales prices must be higher than purchase prices or exceptions will be thrown. Essential items' sales prices can be maximum 25% above cost or another exception occurs. A Product class is to be created with getter/setter methods and overrides for toString(), hashCode(), and equals() to store items in a collection that rejects duplicates. PriceException, EssentialCommodityException, and GradeMismatchException classes also need to be created along with a main method to accept item details as comma separated strings and display the accepted items list.

Uploaded by

Lone One
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Create Getter and Setter Method, Override Tostring With: String - Format ("%-5S %-20S %-10S %-10S %-5S",.... )

The document describes requirements for a Fair Shop application to manage stock of consumable goods. It needs to track each item's unique ID, name, purchase and sales prices, and grade. Sales prices must be higher than purchase prices or exceptions will be thrown. Essential items' sales prices can be maximum 25% above cost or another exception occurs. A Product class is to be created with getter/setter methods and overrides for toString(), hashCode(), and equals() to store items in a collection that rejects duplicates. PriceException, EssentialCommodityException, and GradeMismatchException classes also need to be created along with a main method to accept item details as comma separated strings and display the accepted items list.

Uploaded by

Lone One
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Fair Shop requires to stock consumable goods.

Every good item has an unique id, name,


purchase price, sales price, grade. Sales price must be higher than purchase price
otherwise an exception will be thrown. Grade value is either “N” (normal commodity) or
“E” (essential commodity) . E graded items sales price cannot be more than 25% of
purchase price otherwise it will throw an exception. Finally you need to list all items in a
collection that refuses to accept duplicate ids.
Create Product class with member data
Integer id,
String name,
Double purchasedPrice,
Double salesPrice,
String grade
Create getter and setter method, override toString() with String.format("%-5s %-20s
%-10s %-10s %-5s",....);
Override hashCode() and equals().
Create PriceException class
Create EssentialCommodityException class.
Create GradeMismatchException class
Create Main class with method public static void main(String [] arg)-> It will accept the
number of items to accept then each item as a String with comma separate format eg:
1001,Salt,20.00,22.00,E
1002,Biriyani Masala,45.00,55.00,N

Finally display all listed items only. Do not show which are rejected in the list.

You might also like