Tuesday, October 26, 2010

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

public class Pant extends Item 
{
 private int theSize;
 
 public Pant()
 {
  this.setSize(0);
 }
 
 public Pant(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: