Class Bakery

java.lang.Object
  extended by Bakery

public class Bakery
extends Object

A facility for the manufacture of cookies.

Version:
1.0 2015-03-02
Author:
Michael Arkin

Constructor Summary
Bakery()
           
 
Method Summary
 void bake(int quantity)
          Bakes the specified number of cookies, each with random characteristics.
 Cookie listFirst(float minimum)
          Lists this bakery's first cookie with a weight at least as great as specified.
 Cookie listFirst(int minimum)
          Lists this bakery's first cookie with a calorie count at least as great as specified.
 String listVegetarian(boolean safe)
          Lists this bakery's cookies which are or are not safe for vegetarians.
 void listWares()
          Lists this bakery's wares with corresponding identification numbers.
 Cookie sellCookie(int number)
          Removes from this bakery's wares a cookie with the specified identification number.
 String toString()
          Returns a string representation of this bakery.
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bakery

public Bakery()
Method Detail

bake

public void bake(int quantity)
Bakes the specified number of cookies, each with random characteristics.

Parameters:
quantity - the number of cookies to be baked; must be > 0

listFirst

public Cookie listFirst(float minimum)
Lists this bakery's first cookie with a weight at least as great as specified.

Parameters:
minimum - the minimum weight sought; must be > 0
Returns:
the first cookie, if one with the specified minimum exists; otherwise, null

listFirst

public Cookie listFirst(int minimum)
Lists this bakery's first cookie with a calorie count at least as great as specified.

Parameters:
minimum - the minimum calorie count sought; must be > 0
Returns:
the first cookie, if one with the specified minimum exists; otherwise, null

listVegetarian

public String listVegetarian(boolean safe)
Lists this bakery's cookies which are or are not safe for vegetarians.

Parameters:
safe - true if the list is to be of vegetarian-safe cookies; otherwise,
Returns:
a string listing vegetarian-safe cookies

listWares

public void listWares()
Lists this bakery's wares with corresponding identification numbers.

NB: Identification numbers are not constant; applications should not depend on a particular type of cookie having a particular identification number.


sellCookie

public Cookie sellCookie(int number)
Removes from this bakery's wares a cookie with the specified identification number.

Parameters:
number - the identifier of the type of cookie to be sold
Returns:
the cookie sold, if a cookie with the specified identifier exists; otherwise, null

toString

public String toString()
Returns a string representation of this bakery.

Overrides:
toString in class Object
Returns:
a string representing this bakery