Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- public class Apple
- {
- //attributes, fields, instance variables
- private Color color;
- private int size; //in cm
- private String texture;
- private int crispness; //some metric scale 1 to 10
- private String name;
- //contructors
- public Apple() //default, red delicious
- {
- Color red = new Color(720002);
- setColor(red);
- setSize(10);
- setTexture ("waxed");
- setCrispness(5);
- setName ("Red Delicious");
- }
- public Apple (int cs, String nm)
- {
- setCrispness(cs);
- setName(nm);
- setSize(10);
- setTexture ("waxed");
- Color red = new Color(720002);
- setColor(red);
- }
- public Apple(Color c, int s, String t, int cr, String n)
- {
- setColor(c);
- setSize(s);
- setTexture (t);
- setCrispness(cr);
- setName (n);
- }
- //behaviors, methods
- //setter methods, mutator methods
- public void setColor(Color color)
- {
- color = color;
- }
- public void setName(String nm)
- {
- name = nm;
- }
- public void setTexture(String tx)
- {
- texture = tx;
- }
- public void setSize(int sz)
- {
- size = sz;
- }
- public void setCrispness(int cp)
- {
- crispness = cp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement