type.lib
Class AbstractFoods

java.lang.Object
  extended by type.lib.AbstractFoods
All Implemented Interfaces:
java.io.Serializable

public class AbstractFoods
extends java.lang.Object
implements java.io.Serializable

This class encapsulates the inventory and sales business of the Abstract Foods Company. It maintains three collections:

All three collections do not use generics, i.e. their elements are of type Object.

Version:
7.0 - Summer 2010
Author:
H. Roumani, roumani@cse.yorku.ca
See Also:
Serialized Form

Constructor Summary
AbstractFoods()
          Construct a company having empty collections.
AbstractFoods(java.util.Map<java.lang.String,Item> inventory, java.util.Map<java.lang.String,Contact> contacts, java.util.List<Trx> journal)
          Construct a company having the passed collections.
 
Method Summary
 java.util.Map<java.lang.String,Contact> getContacts()
          Determine the contacts map of this company
 java.util.Map<java.lang.String,Item> getInventory()
          Determine the inventory map of this company
 java.util.List<Trx> getJournal()
          Determine the transaction list of this company
static AbstractFoods getRandom()
          Create a randomly chosen Abstract Foods Company.
 java.lang.String toString()
          Construct a string representation of this company.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractFoods

public AbstractFoods()
Construct a company having empty collections.


AbstractFoods

public AbstractFoods(java.util.Map<java.lang.String,Item> inventory,
                     java.util.Map<java.lang.String,Contact> contacts,
                     java.util.List<Trx> journal)
Construct a company having the passed collections.

Parameters:
inventory - the inventory map
contacts - the contacts map
journal - the transaction list
Method Detail

getInventory

public java.util.Map<java.lang.String,Item> getInventory()
Determine the inventory map of this company

Returns:
the inventory map

getContacts

public java.util.Map<java.lang.String,Contact> getContacts()
Determine the contacts map of this company

Returns:
the contacts map

getJournal

public java.util.List<Trx> getJournal()
Determine the transaction list of this company

Returns:
the transaction list

toString

public java.lang.String toString()
Construct a string representation of this company.

Overrides:
toString in class java.lang.Object
Returns:
the string: "Abstract Foods Company".

getRandom

public static AbstractFoods getRandom()
Create a randomly chosen Abstract Foods Company. The inventory map consists of about 100 (item number, Item) mappings of which about 25% are for Fresh items. The numbers, names, and prices are randomly chosen but the numbers are 8-character each. The contacts map consists of about 100 (contact number, Contact) mappings of which 50% are Client and 50% are Supplier instances. The numbers, names, ratings (for clients), and catalogues (for suppliers) are randomly chosen but the numbers are formatted as 5-digit each. The journal list consists of about 750 posted Trx transactions spanning approximately 4 months (with the latest occurring in the past 48 hours).

In order to facilitate the testing of front-ends and reports that are based on this randomly-chosen company, it is persisted (serialized) by storing the returned instance on disk in the file data.af.

This method was added for pedagogical reasons.

Returns:
a company with randomly chosen collections.


Java by Abstraction: A Client-View Approach