Tuesday, October 26, 2010

LabTest#2: Revised Solution -- Section 6 -- Class: Shirt

public class Shirt extends Item
{
 
public enum Size { S, M, L, XL };
 
private Size theSize;
 
 
public Shirt()
 
{
 
this.setSize(Size.S);
 
}
 
 
public Shirt(String n, int p, Size s)
 
{
 
super(n, p);
 
this.setSize(s);
 
}
 
 
public void setSize(Size s)
 
{
  theSize
= s;
 
}
 
 
public Size getSize()
 
{
 
return theSize;
 
}
 
 
public String toString()
 
{
 
String str;
  str
= String.format("Item Name:%s Item Price:%d Item Size:%s", super.getName(), super.getPrice(), this.getSize().toString());
 
return str;
 
}
 
}

No comments: