Developer's Daily Java Education - Test Projects
  front page | java | perl | unix | DevDirectory
   
Front Page
Java
Education
   
 


import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;

public class Pizza
{
  private int crustType;
  private int crustSize;
  private double price;
  private List toppings;

  public static final int THIN_CRUST_TYPE  = 1;
  public static final int THICK_CRUST_TYPE = 2;
  public static final int DEFAULT_CRUST_TYPE = THICK_CRUST_TYPE;

  public static final int SMALL_CRUST_SIZE  = 1;
  public static final int MEDIUM_CRUST_SIZE = 2;
  public static final int LARGE_CRUST_SIZE  = 3;
  public static final int DEFAULT_CRUST_SIZE  = MEDIUM_CRUST_SIZE;

  public Pizza()
  {
    toppings = new LinkedList();
    crustType = DEFAULT_CRUST_TYPE;
    crustSize = DEFAULT_CRUST_SIZE;
  }

  public void addTopping(String topping)
  {
    toppings.add(topping);
  }

  public int getCrustType()
  {
    return crustType;
  }

  public void setCrustType(int newCrustType)
  {
    crustType = newCrustType;
  }

  public void setCrustSize(int newCrustSize)
  {
    crustSize = newCrustSize;
  }

  public int getCrustSize()
  {
    return crustSize;
  }

  public void setPrice(double newPrice)
  {
    price = newPrice;
  }

  public double getPrice()
  {
    return price;
  }

  public void setToppings(java.util.List newToppings)
  {
    toppings = newToppings;
  }

  public java.util.List getToppings()
  {
    return toppings;
  }
}
Copyright 1998-2003 DevDaily Interactive, Inc.
All Rights Reserved.