Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * written by tariq scott
- */
- public class Apple {
- // variables
- private String name;
- private double weight;
- private double price;
- //constructors
- public Apple () //Default
- {
- this.name = "undefined name";
- this.weight = 0.0;
- this.price = 0.0;
- }
- public Apple (String aName, double aWeight, double aPrice)
- {
- //Get the names
- }
- public String getName()
- {
- return this.name;
- }
- public double getWeight ()
- {
- return this.weight;
- }
- public double getPrice()
- {
- return this.price;
- }
- //Mutators
- public void setName(String aName)
- {
- this.name = aName;
- }
- public void setWeight(double aWeight)
- {
- if (aWeight <= 2.0 && aWeight >=0.0);
- {
- this.weight = aWeight;
- }
- }
- //Other Methods
- public String toString()
- {
- return this.name + " " + this.weight + " " + this.price;
- }
- public boolean equals (Apple aApple)
- {
- return aApple != null &&
- this.name.equals(aApple.getName()) &&
- this.weight == aApple.getWeight() &&
- this.price == aApple.getPrice ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement