/    Sign up×
Community /Pin to ProfileBookmark

Help With Test Class Urgent

Allright i had a prompt to follow for my class and wrote upa regular file here is the prompt

  • 4.

    Implement a class Product. A product has a name and a price, for example:

    new Product(“Toaster”, 29.95);

  • Supply methods getName(), getPrice(), and setPrice(double newPrice). Write a client program that makes two products, prints the name and price, and reduces their prices by $5.00, and then prints them again.

    here is my original file
    /*Product.java
    *
    A program that creates a product
    *Author: Habeeb Syed
    *
    9/28/05
    */
    public class Product //Creates a Product class
    {
    private String name;
    private double price;
    public Product(String aName, double initialPrice)
    {
    price = initialPrice;
    name = aName;
    price = 0.0;
    }
    public String getName() //Returns name of the product
    {
    String aName=name;
    return name;
    }
    public double getPrice() //Returns price of the product
    {
    double initialPrice=price;
    return price;
    }
    public double setPrice(double newPrice) //gives the new price of the product
    {
    price=newPrice;
    return newPrice;
    }
    }

    now I need to make a test class that does what the prompt states if neone can help me out it would be appreciated.

    to post a comment
    JavaScript

    4 Comments(s)

    Copy linkTweet thisAlerts:
    @PAKIauthorOct 04.2005 — plz someone help me out.
    Copy linkTweet thisAlerts:
    @VladdyOct 04.2005 — Can someone give this guy a polite answer, before I get myself in trouble :rolleyes:
    Copy linkTweet thisAlerts:
    @webstuffOct 04.2005 — JAVA IS NOT JAVASCRIPT................. <- Clue!

    Its like using a screwdriver to hammer in nails...
    ×

    Success!

    Help @PAKI spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.13,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...