Advertisement
MrsMcLead

Apple

Feb 8th, 2016
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import java.awt.Color;
  2.  
  3. public class Apple
  4. {
  5.   //attributes, fields, instance variables
  6.  
  7.   private Color color;
  8.   private int size; //in cm
  9.   private String texture;
  10.   private int crispness;  //some metric scale 1 to 10
  11.   private String name;
  12.  
  13.  
  14.   //contructors
  15.  
  16.   public Apple()  //default, red delicious
  17.   {
  18.     Color red = new Color(720002);
  19.     setColor(red);
  20.     setSize(10);
  21.     setTexture ("waxed");
  22.     setCrispness(5);
  23.     setName ("Red Delicious");    
  24.   }
  25.  
  26.   public Apple (int cs, String nm)
  27.   {
  28.     setCrispness(cs);
  29.     setName(nm);
  30.     setSize(10);
  31.     setTexture ("waxed");
  32.      Color red = new Color(720002);
  33.     setColor(red);    
  34.   }
  35.  
  36.  
  37.   public Apple(Color c, int s, String t, int cr, String n)
  38.   {
  39.     setColor(c);
  40.     setSize(s);
  41.     setTexture (t);
  42.     setCrispness(cr);
  43.     setName (n);    
  44.   }
  45.  
  46.   //behaviors, methods
  47.  
  48.   //setter methods, mutator methods
  49.   public void setColor(Color color)
  50.   {
  51.    color = color;
  52.   }
  53.  
  54.   public void setName(String nm)
  55.   {
  56.    name = nm;
  57.   }
  58.  
  59.   public void setTexture(String tx)
  60.   {
  61.     texture = tx;
  62.   }
  63.  
  64.   public void setSize(int sz)
  65.   {
  66.     size = sz;
  67.   }
  68.  
  69.   public void setCrispness(int cp)
  70.   {
  71.     crispness = cp;
  72.   }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement