Tuesday, October 26, 2010

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

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

No comments: