need help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: need help

Hybrid View

  1. #1
    Join Date
    Nov 2012
    Location
    usa
    Posts
    3

    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.

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: need help

    Ok so that's your homework, what's your question?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Jan 2009
    Posts
    596

    Re: need help

    Quote Originally Posted by wojo007 View Post
    2. An equals method that compares two Products and returns true if they’re the same price
    Whoever wrote the specifications for this was a bit sloppy. Simply returning 'true' for any input would fulfil this requirement

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center