|
-
November 14th, 2012, 02:31 PM
#1
need help
Create a class called Product. The class should have private fields for:
1. The product name
2. The product price
The class should have the following methods:
1. a toString method that displays the name of the product and its price.
2. An equals method that compares two Products and returns true if they’re the same price
3. Get and set methods for the private fields
4. Any necessary constructors
The class should throw an IllegalArgumentException when a user attempts to set a price less than 0.
The class should throw an IllegalNameException when a user attempts to set a name equal to the empty string.
The IllegalNameException should be a derived class based on the IllegalArgumentException class.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|