#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  csc324 csc324/clothes csc324/csc324.map csc324/csc324.prj
#   csc324/driver csc324/util csc324/clothes/Bottom.java
#   csc324/clothes/CasualShirt.java csc324/clothes/Clothes.java
#   csc324/clothes/ClothingInventory.java
#   csc324/clothes/DressPants.java csc324/clothes/DressShirt.java
#   csc324/clothes/InformalShirt.java csc324/clothes/Jeans.java
#   csc324/clothes/Pants.java csc324/clothes/Shorts.java
#   csc324/clothes/Sweater.java csc324/clothes/TShirt.java
#   csc324/clothes/Top.java csc324/clothes/clothes.map
#   csc324/clothes/clothes.prj csc324/driver/Driver.java
#   csc324/driver/driver.map csc324/driver/driver.prj
#   csc324/util/VectorManipulator.java csc324/util/util.map
#   csc324/util/util.prj
# Wrapped by pgries@gardiner.cs on Wed Jan 27 10:47:26 1999
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d 'csc324' ; then
    echo shar: Creating directory \"'csc324'\"
    mkdir 'csc324'
fi
if test ! -d 'csc324/clothes' ; then
    echo shar: Creating directory \"'csc324/clothes'\"
    mkdir 'csc324/clothes'
fi
if test -f 'csc324/csc324.map' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/csc324.map'\"
else
echo shar: Extracting \"'csc324/csc324.map'\" \(11 characters\)
sed "s/^X//" >'csc324/csc324.map' <<'END_OF_FILE'
XVERSION: 1
END_OF_FILE
if test 11 -ne `wc -c <'csc324/csc324.map'`; then
    echo shar: \"'csc324/csc324.map'\" unpacked with wrong size!
fi
# end of 'csc324/csc324.map'
fi
if test -f 'csc324/csc324.prj' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/csc324.prj'\"
else
echo shar: Extracting \"'csc324/csc324.prj'\" \(212 characters\)
sed "s/^X//" >'csc324/csc324.prj' <<'END_OF_FILE'
Xsun.jws.version.2
Xsun.jws.classname=csc324
Xsun.jws.useVisual=false
Xsun.jws.type=package
Xsun.jws.classdir=../
Xsun.jws.options=-g
Xsun.jws.includes=List
Xutil/util.prj
Xclothes/clothes.prj
Xdriver/driver.prj
XEndOfList
END_OF_FILE
if test 212 -ne `wc -c <'csc324/csc324.prj'`; then
    echo shar: \"'csc324/csc324.prj'\" unpacked with wrong size!
fi
# end of 'csc324/csc324.prj'
fi
if test ! -d 'csc324/driver' ; then
    echo shar: Creating directory \"'csc324/driver'\"
    mkdir 'csc324/driver'
fi
if test ! -d 'csc324/util' ; then
    echo shar: Creating directory \"'csc324/util'\"
    mkdir 'csc324/util'
fi
if test -f 'csc324/clothes/Bottom.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/Bottom.java'\"
else
echo shar: Extracting \"'csc324/clothes/Bottom.java'\" \(1282 characters\)
sed "s/^X//" >'csc324/clothes/Bottom.java' <<'END_OF_FILE'
X// class Bottom: represents Clothes worn on the bottom half of the body.
X
Xpackage csc324.clothes;
Ximport java.util.*;
Ximport csc324.util.*;
X
Xpublic abstract class Bottom extends Clothes {
X
X    //---
X    private static Vector attributes = new Vector();
X
X    //---
X    public static Enumeration attributes() {
X	return attributes.elements();
X    }
X
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X
X    int waistSize;
X    static int minWaistSize, maxWaistSize;
X	
X    static {
X	minWaistSize = 28;
X	maxWaistSize = 44;
X	name = "bottom";
X	VectorManipulator.addItemsToVector(attributes,
X					   Clothes.attributes());
X        attributes.addElement( "waist size" );
X    }
X
X    // Return true if my values are valid.
X    public boolean isValid() {
X	return ( super.isValid() &&
X		 minWaistSize <= waistSize &&
X		 maxWaistSize >= waistSize );
X    }
X
X    // Set my waist size to i.
X    public void setWaistSize( int i ) {
X        this.waistSize = i;
X    }
X
X    // Constructor; build myself from the info in ht.
X    public Bottom( Hashtable ht ) throws Exception {
X	super( ht );
X        setWaistSize(Integer.parseInt( (String)ht.get("waist size") ) );
X    }
X	
X    public String toString() {
X	return super.toString() + "  waist size:" + waistSize;
X    }
X}
END_OF_FILE
if test 1282 -ne `wc -c <'csc324/clothes/Bottom.java'`; then
    echo shar: \"'csc324/clothes/Bottom.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/Bottom.java'
fi
if test -f 'csc324/clothes/CasualShirt.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/CasualShirt.java'\"
else
echo shar: Extracting \"'csc324/clothes/CasualShirt.java'\" \(528 characters\)
sed "s/^X//" >'csc324/clothes/CasualShirt.java' <<'END_OF_FILE'
X// class CasualShirt: represents casual shirts.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
X
Xpublic class CasualShirt extends InformalShirt {
X
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "casual shirt";
X	minPrice = 10;
X	maxPrice = 50;
X    }
X
X    // Constructor; build myself from the info in ht.
X    public CasualShirt( Hashtable ht ) throws Exception {
X	super( ht );
X    }
X
X    public String toString() {
X	return this.name + ": " + super.toString();
X    }
X}
END_OF_FILE
if test 528 -ne `wc -c <'csc324/clothes/CasualShirt.java'`; then
    echo shar: \"'csc324/clothes/CasualShirt.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/CasualShirt.java'
fi
if test -f 'csc324/clothes/Clothes.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/Clothes.java'\"
else
echo shar: Extracting \"'csc324/clothes/Clothes.java'\" \(3518 characters\)
sed "s/^X//" >'csc324/clothes/Clothes.java' <<'END_OF_FILE'
X// class Clothes: the root class of the Clothes hierarchy.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
X
Xpublic abstract class Clothes {
X    // STATIC MEMBERS.
X	
X    private static String name;	// My type as a String.
X    public static String getName() {
X	return name;
X    }
X
X    // My list of attributes and corresponding values.
X    protected static Vector attributes = new Vector(); 
X
X    // The upper and lower bounds on my price, in dollars.
X    static int minPrice, maxPrice;
X    
X    // The list of valid colours.
X    static Vector validColours = new Vector();
X
X    // The list of valid fabrics.
X    static Vector validFabrics = new Vector();
X
X    // Initialize my static members.
X    static {
X	name = "clothes";
X		
X        attributes.addElement("colour"); 
X        attributes.addElement("price"); 
X        attributes.addElement("fabric"); 
X
X        validColours.addElement("persimmon");
X        validColours.addElement("blue");
X        validColours.addElement("white");
X        validColours.addElement("black");
X        validColours.addElement("brown");
X        validColours.addElement("paisley");
X        validColours.addElement("plaid");
X
X	validFabrics.addElement("cotton");
X	validFabrics.addElement("wool");
X	validFabrics.addElement("polyester");
X	validFabrics.addElement("acrylic");
X    }
X
X    // Return a list of my attributes.
X    public static Enumeration attributes() {
X        return attributes.elements();
X    }
X 
X    // Return a list of valid colours.
X    public static Enumeration getValidColours() {
X	return validColours.elements();
X    }
X
X    // Return a list of valid fabrics.
X    public static Enumeration getValidFabrics() {
X	return validFabrics.elements();
X    }
X
X    // Return my lowest possible price.
X    public static int getMinPrice() { return minPrice; }
X
X    // Return my highest possible price.
X    public static int getMaxPrice() { return maxPrice; }
X    
X    // INSTANCE VARIABLES.
X	
X    String colour;	// My colour.
X    String fabric;	// My fabric.
X    int price;		// My price, in dollars.
X    
X    // Constructor; build myself from the info in ht.
X    public Clothes(Hashtable ht) throws Exception {
X	setColour( (String)ht.get("colour") );
X	setFabric( (String)ht.get("fabric"));
X	setPrice( Integer.parseInt((String)ht.get("price"))); 
X    }
X 
X    // Set my price to c.
X    public void setPrice( int c ) { price = c; }
X    public int getPrice() { return price; }         // Return my price.
X
X    // Set my colour to c.
X    public void setColour( String c ) { colour = c; }
X    public String getColour() { return colour; }    // Return my colour.
X
X    // Set my fabric type to f.
X    public void setFabric( String f ) { fabric = f; }
X    public String getFabric() { return fabric; }    // Return my fabric.
X
X    // Return true if my colour is valid.
X    boolean hasValidColour() {
X    	return validColours.contains(colour);
X    }
X
X    // Return true if my fabric is valid.
X    boolean hasValidFabric() {
X    	return validFabrics.contains(fabric);
X    }
X
X    // Return true if my colour is valid.
X    boolean hasValidPrice() {
X    	return minPrice <= price && price <= maxPrice;
X    }
X
X    // Return true if my attributes are all valid.
X    public boolean isValid() {
X    	return ( hasValidColour() &&
X		 hasValidFabric() &&
X		 hasValidPrice() );
X    }
X
X    // Return my representation as a String.
X    public String toString() {
X	return "  colour:" + getColour() + "  fabric:" +
X	    getFabric() + "  price:" + getPrice();
X    }
X
X    public String gName() {
X	return name;
X    }
X
X}
END_OF_FILE
if test 3518 -ne `wc -c <'csc324/clothes/Clothes.java'`; then
    echo shar: \"'csc324/clothes/Clothes.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/Clothes.java'
fi
if test -f 'csc324/clothes/ClothingInventory.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/ClothingInventory.java'\"
else
echo shar: Extracting \"'csc324/clothes/ClothingInventory.java'\" \(5537 characters\)
sed "s/^X//" >'csc324/clothes/ClothingInventory.java' <<'END_OF_FILE'
X// class ClothingInventory: maintain an inventory of clothing that can be
X// bought and sold.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
Ximport java.lang.reflect.*; 
X
Xpublic class ClothingInventory {
X    // The total amount of money I've made.
X    private int totalSales;
X
X    private static final int MAX_CLOTHES = 100;
X
X    // My items.
X    private Clothes[] items = new Clothes[MAX_CLOTHES];
X
X    // The number of items I currently contain.
X    private int numItems;
X
X    // Pairs of Strings and corresponding clothes classes available to me.
X    private static Hashtable classTable = new Hashtable();
X    
X    // Pairs of Strings and corresponding clothes classes
X    // available to me, including abstract classes.
X    private static Hashtable allClassTable = new Hashtable();
X    
X
X    // This is a static initializer; it gets called once, to set up static
X    // instance variables.
X    static {
X        classTable.put(CasualShirt.getName(), CasualShirt.class);
X        classTable.put(DressPants.getName(), DressPants.class);
X        classTable.put(DressShirt.getName(), DressShirt.class);
X        classTable.put(Jeans.getName(), Jeans.class);
X        classTable.put(Shorts.getName(), Shorts.class);
X        classTable.put(Sweater.getName(), Sweater.class);
X        classTable.put(TShirt.getName(), TShirt.class);
X
X    	allClassTable = (Hashtable)classTable.clone();
X        allClassTable.put(InformalShirt.getName(), InformalShirt.class);
X        allClassTable.put(Top.getName(), Top.class);
X        allClassTable.put(Bottom.getName(), Bottom.class);
X        allClassTable.put(Pants.getName(), Pants.class);
X        allClassTable.put(Clothes.getName(), Clothes.class);
X    }
X
X
X    // Return the list of clothing types that I maintain.
X    public Enumeration getClothingTypes() {
X	return classTable.keys();
X    }
X
X
X    // Return the list of clothing types that I maintain, including
X    // general categories.
X    public Enumeration getAllClothingTypes() {
X	return allClassTable.keys();
X    }
X
X
X    // Return a Vector containing the items in me.
X    public Vector getItems() {
X	Vector v = new Vector();
X	for( int i=0; i<numItems; i++ ) {
X	    v.addElement( items[i] );
X	}
X
X	return v;
X    }
X
X
X    // Return the Class associated with key.
X    public Class getClass( String key ) {
X	return (Class)allClassTable.get( key );
X    }
X
X
X    // Sell item c from me.
X    public void sellItem( Clothes c ) {
X	totalSales += c.getPrice();
X	removeItem( c );
X    }
X
X
X    // Return my number of items.
X    public int size() {
X	return numItems;
X    }
X
X
X    // Return the number of items that are of type s.
X    public int countItemType( String s ) {
X	Class cl = getClass( s );
X
X	int itemCount = 0;
X
X	for( int i=0; i<numItems; i++ ) {
X	    if( cl.isInstance( items[i] ) ) {
X		itemCount++;
X	    }
X	}
X
X	return itemCount;
X    }
X
X
X    // Return the total amount of money made, in dollars.
X    public int totalSales() {
X	return totalSales;
X    }
X
X
X    // Remove c from me.
X    private void removeItem( Clothes c ) {
X	for( int i=0; i<numItems; i++ ) {
X	    if( items[i] == c ) {
X		items[i] = items[ --numItems ];
X	    }
X	}
X    }
X
X
X    // Add c to me.
X    private void addItem( Clothes c ) {
X	items[numItems++] = c;
X    }
X
X
X    // Add a clothing item of type s with attributes in ht.
X    public void addItem( String s, Hashtable ht ) throws Exception {
X
X	// This is a cool way to construct new instances, and it avoids the
X	// problems with maintaining large if-then-else statements.  Don't
X	// worry about it for now; we'll cover this topic in the next
X	// tutorial.
X
X	Class[] clothesClassConstructorParametersClasses = {Hashtable.class};
X	Object[] clothesClassConstructorParameters = {ht};
X	
X	// The following uncommented line does the same thing as the
X	// four lines after it.
X	
X	// this.addItem(
X	//    (Clothes)((Class)classTable.get(s)).
X	//    getConstructor(clothesClassConstructorParametersClasses).
X	//    newInstance(clothesClassConstructorParameters));
X
X	Class clothesClass = (Class)classTable.get(s);
X	Constructor clothesClassConstructor = 
X	    clothesClass.getConstructor(
X		clothesClassConstructorParametersClasses);
X	Clothes clothesInstance = 
X	    (Clothes)clothesClassConstructor.
X	    newInstance(clothesClassConstructorParameters);
X
X	if( clothesInstance.isValid() ) {
X	    this.addItem(clothesInstance);
X	} else {
X	    System.out.println( "Bad item specs, try again." );
X	}
X	
X    }
X
X
X    // Return the attributes for an item of type s.
X    public static Enumeration attributesForItemType( String s )
X	throws Exception {
X
X	// This is a cool way to get attributes for new instances, and it
X	// avoids the problems with maintaining large if-then-else
X	// statements.  Don't worry about it for now; we'll cover this topic
X	// in the next tutorial.
X
X	Class[] clothesClassAttributeMethodParametersClasses = 
X	    new Class[0];
X	Object[] clothesClassAttributeMethodParameters = new Object[0];
X	
X	// The following uncommented line does the same thing as the
X	// the four lines after it.
X	
X	// return (Enumeration)(
X	//	(Class)classTable.get(s)).
X	//	getMethod("attributes", 
X	//		  clothesClassAttributeMethodParametersClasses).
X	//	invoke(null, clothesClassAttributeMethodParameters);
X	
X	Class clothesClass = (Class)classTable.get(s);
X	Method clothesAttributesMethod =
X	    clothesClass.getMethod("attributes",
X				   clothesClassAttributeMethodParametersClasses);
X
X	Enumeration clothesAttributes = 
X	    (Enumeration)clothesAttributesMethod.
X	    invoke(null, clothesClassAttributeMethodParameters);
X
X	return clothesAttributes;
X    }
X
X}
END_OF_FILE
if test 5537 -ne `wc -c <'csc324/clothes/ClothingInventory.java'`; then
    echo shar: \"'csc324/clothes/ClothingInventory.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/ClothingInventory.java'
fi
if test -f 'csc324/clothes/DressPants.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/DressPants.java'\"
else
echo shar: Extracting \"'csc324/clothes/DressPants.java'\" \(693 characters\)
sed "s/^X//" >'csc324/clothes/DressPants.java' <<'END_OF_FILE'
X// class DressPants: represents dress pants.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
X
Xpublic class DressPants extends Pants {
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "dress pants";
X	minPrice = 40;
X	maxPrice = 120;
X    }
X
X    // Return true if my size, colour, fabric, and price are all valid.
X    public boolean isValid() {
X    	return ( super.isValid() &&
X		 !(fabric.equals("polyester")) );
X    }
X
X    // Constructor; build myself from the info in ht.
X    public DressPants( Hashtable ht ) throws Exception {
X	super( ht );
X    }
X
X    public String toString() {
X	return this.name + ": " + super.toString();
X    }
X}
END_OF_FILE
if test 693 -ne `wc -c <'csc324/clothes/DressPants.java'`; then
    echo shar: \"'csc324/clothes/DressPants.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/DressPants.java'
fi
if test -f 'csc324/clothes/DressShirt.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/DressShirt.java'\"
else
echo shar: Extracting \"'csc324/clothes/DressShirt.java'\" \(1489 characters\)
sed "s/^X//" >'csc324/clothes/DressShirt.java' <<'END_OF_FILE'
X// class DressPants: represents dress shirts.
X
Xpackage csc324.clothes;
Ximport csc324.util.*;
Ximport java.util.*;
X
Xpublic class DressShirt extends Top {
X    // My collar size.
X    int collarSize;
X	
X    //---
X    private static Vector attributes = new Vector();
X
X    //---
X    public static Enumeration attributes() {
X	return attributes.elements();
X    }
X
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static int maxCollarSize, minCollarSize;
X
X    static {
X	name = "dress shirt";
X
X	VectorManipulator.addItemsToVector(attributes,
X					   Top.attributes());
X        attributes.addElement("collar size");
X
X	minCollarSize = 13;
X	maxCollarSize = 21;
X	minPrice = 30;
X	maxPrice = 60;
X    }
X
X    // Set my collar size to s.
X    public void setCollarSize( String s ) {
X        this.collarSize = Integer.parseInt( s );
X    }
X
X    // Constructor; build myself from the info in ht.
X    public DressShirt( Hashtable ht ) throws Exception {
X	super( ht );
X	setCollarSize( (String) ht.get( "collar size" ) );
X    }
X
X    // Return true if my values are valid.
X    public boolean isValid() {
X	return ( super.isValid() &&
X		 minCollarSize <= collarSize &&
X		 maxCollarSize >= collarSize &&
X		 !( colour.equals("persimmon") ||
X		    colour.equals("plaid") ||
X		    colour.equals("paisley") ) );
X    }
X
X    // Return my representation as a String.
X    public String toString() {
X	return this.name + ": " + super.toString() + "  collar size:" + collarSize;
X    }
X}
END_OF_FILE
if test 1489 -ne `wc -c <'csc324/clothes/DressShirt.java'`; then
    echo shar: \"'csc324/clothes/DressShirt.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/DressShirt.java'
fi
if test -f 'csc324/clothes/InformalShirt.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/InformalShirt.java'\"
else
echo shar: Extracting \"'csc324/clothes/InformalShirt.java'\" \(1314 characters\)
sed "s/^X//" >'csc324/clothes/InformalShirt.java' <<'END_OF_FILE'
X// class InformalShirt: represents informal shirts that are measured by
X// small, medium and large.
X
Xpackage csc324.clothes;
Ximport csc324.util.*;
Ximport java.util.*;
X
Xpublic class InformalShirt extends Top {
X
X    //---
X    private static Vector attributes = new Vector();
X
X    //---
X    public static Enumeration attributes() {
X	return attributes.elements();
X    }
X
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "informal shirt";
X
X	VectorManipulator.addItemsToVector(attributes,
X					   Top.attributes());
X        attributes.addElement("size");
X
X	minPrice = 10;
X	maxPrice = 50;
X    }
X
X    // One of small, medium and large.
X    String size;
X
X    // Set my size to s.
X    public void setSize( String s ) {
X        this.size = s;
X    }
X
X    // Constructor; build myself from the info in ht.
X    public InformalShirt( Hashtable ht ) throws Exception {
X	super( ht );
X        setSize( (String)ht.get("size") );
X    }
X
X    // Return true if my values are valid.
X    public boolean isValid() {
X	return ( super.isValid() &&
X		 ( size.equals( "small" ) ||
X		   size.equals( "medium" ) ||
X		   size.equals( "large" ) ) );
X    }
X
X    // Return my representation as a String.
X    public String toString() {
X	return super.toString() + "  size:" + size;
X    }
X}
END_OF_FILE
if test 1314 -ne `wc -c <'csc324/clothes/InformalShirt.java'`; then
    echo shar: \"'csc324/clothes/InformalShirt.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/InformalShirt.java'
fi
if test -f 'csc324/clothes/Jeans.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/Jeans.java'\"
else
echo shar: Extracting \"'csc324/clothes/Jeans.java'\" \(699 characters\)
sed "s/^X//" >'csc324/clothes/Jeans.java' <<'END_OF_FILE'
X// class Jeans: represents jeans.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
X
Xpublic class Jeans extends Pants {
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "jeans";
X	minPrice = 30;
X	maxPrice = 50;
X    }
X
X    // Constructor; build myself from the info in ht.
X    public Jeans( Hashtable ht ) throws Exception {
X	super( ht );
X    }
X
X    // Return true if my values are valid.
X    public boolean isValid() {
X	return ( super.isValid() &&
X		 fabric.equals("cotton") &&
X		 colour.equals("blue") );
X    }
X
X    // Return my representation as a String.
X    public String toString() {
X	return this.name + ": " + super.toString();
X    }
X}
END_OF_FILE
if test 699 -ne `wc -c <'csc324/clothes/Jeans.java'`; then
    echo shar: \"'csc324/clothes/Jeans.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/Jeans.java'
fi
if test -f 'csc324/clothes/Pants.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/Pants.java'\"
else
echo shar: Extracting \"'csc324/clothes/Pants.java'\" \(1386 characters\)
sed "s/^X//" >'csc324/clothes/Pants.java' <<'END_OF_FILE'
X// class Pants: represents clothing measured by inseam length.
X
Xpackage csc324.clothes;
Ximport csc324.util.*;
Ximport java.util.*;
X
Xpublic abstract class Pants extends Bottom {
X    // The length of my inseam.
X    int inseamLength;
X	
X    //---
X    private static Vector attributes = new Vector();
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static int minInseamLength, maxInseamLength;
X
X    static {
X	name = "pants";
X
X	VectorManipulator.addItemsToVector(attributes,
X					   Bottom.attributes());
X        attributes.addElement("inseam length");
X
X	minInseamLength = 28;
X	maxInseamLength = 40;
X    }
X
X    //---
X    public static Enumeration attributes() {
X	return attributes.elements();
X    }
X
X    // Set my inseam to i.
X    public void setInseamLength( int i ) {
X        this.inseamLength = i;
X    }
X
X    // Constructor; build myself from the info in ht.
X    public Pants( Hashtable ht ) throws Exception {
X	super( ht );
X        setInseamLength(Integer.parseInt( (String)ht.get("inseam length") ) );
X    }
X
X
X    // Return true if my values are valid.
X    public boolean isValid() {
X	return ( super.isValid() &&
X		 minInseamLength <= inseamLength &&
X		 maxInseamLength >= inseamLength );
X    }
X
X    // Return my representation as a String.
X    public String toString() {
X	return super.toString() + "  inseam length:" + inseamLength;
X    }
X}
END_OF_FILE
if test 1386 -ne `wc -c <'csc324/clothes/Pants.java'`; then
    echo shar: \"'csc324/clothes/Pants.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/Pants.java'
fi
if test -f 'csc324/clothes/Shorts.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/Shorts.java'\"
else
echo shar: Extracting \"'csc324/clothes/Shorts.java'\" \(538 characters\)
sed "s/^X//" >'csc324/clothes/Shorts.java' <<'END_OF_FILE'
X// class Shorts: represents shorts.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
X
Xpublic class Shorts extends Bottom {
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "shorts";
X	minPrice = 15;
X	maxPrice = 60;
X    }
X
X    // Constructor; build myself from the info in ht.
X    public Shorts( Hashtable ht ) throws Exception {
X	super( ht );
X    }
X	
X    // Return my representation as a String.
X    public String toString() {
X	return this.name + ": " + super.toString();
X    }
X}
END_OF_FILE
if test 538 -ne `wc -c <'csc324/clothes/Shorts.java'`; then
    echo shar: \"'csc324/clothes/Shorts.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/Shorts.java'
fi
if test -f 'csc324/clothes/Sweater.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/Sweater.java'\"
else
echo shar: Extracting \"'csc324/clothes/Sweater.java'\" \(553 characters\)
sed "s/^X//" >'csc324/clothes/Sweater.java' <<'END_OF_FILE'
X// class Sweater: represents sweaters.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
X
Xpublic class Sweater extends InformalShirt {
X
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "sweater";
X	minPrice = 40;
X	maxPrice = 120;
X    }
X	
X    // Constructor; build myself from the info in ht.
X    public Sweater( Hashtable ht ) throws Exception {
X	super( ht );
X    }
X
X    // Return my representation as a String.
X    public String toString() {
X	return this.name + ": " + super.toString();
X    }
X}
END_OF_FILE
if test 553 -ne `wc -c <'csc324/clothes/Sweater.java'`; then
    echo shar: \"'csc324/clothes/Sweater.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/Sweater.java'
fi
if test -f 'csc324/clothes/TShirt.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/TShirt.java'\"
else
echo shar: Extracting \"'csc324/clothes/TShirt.java'\" \(545 characters\)
sed "s/^X//" >'csc324/clothes/TShirt.java' <<'END_OF_FILE'
X// class TShirt: represents tshirts.
X
Xpackage csc324.clothes;
X
Ximport java.util.*;
X
Xpublic class TShirt extends InformalShirt {
X
X    private static String name;
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "tshirt";
X	minPrice = 5;
X	maxPrice = 15;
X    }
X
X    // Constructor; build myself from the info in ht.
X    public TShirt( Hashtable ht ) throws Exception {
X	super( ht );
X    }
X
X    // Return my representation as a String.
X    public String toString() {
X	return this.name + ": " + super.toString();
X    }
X}
END_OF_FILE
if test 545 -ne `wc -c <'csc324/clothes/TShirt.java'`; then
    echo shar: \"'csc324/clothes/TShirt.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/TShirt.java'
fi
if test -f 'csc324/clothes/Top.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/Top.java'\"
else
echo shar: Extracting \"'csc324/clothes/Top.java'\" \(491 characters\)
sed "s/^X//" >'csc324/clothes/Top.java' <<'END_OF_FILE'
X// class Top: represents clothes worn on the top half of the body.
X
Xpackage csc324.clothes;
Ximport java.util.*;
X
X// The root class of Clothes worn on the top of the body.
Xpublic abstract class Top extends Clothes {
X
X    private static String name;	// My type as a String.
X    public static String getName() {
X	return name;
X    }
X
X    static {
X	name = "top";
X    }
X
X    // Constructor; build myself from the info in ht.
X    public Top( Hashtable ht ) throws Exception {
X	super( ht );
X    }
X}
END_OF_FILE
if test 491 -ne `wc -c <'csc324/clothes/Top.java'`; then
    echo shar: \"'csc324/clothes/Top.java'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/Top.java'
fi
if test -f 'csc324/clothes/clothes.map' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/clothes.map'\"
else
echo shar: Extracting \"'csc324/clothes/clothes.map'\" \(576 characters\)
sed "s/^X//" >'csc324/clothes/clothes.map' <<'END_OF_FILE'
XVERSION: 1
XJeans.java,7,35,csc324.clothes.Jeans
XTop.java,7,22,csc324.clothes.Top
XDressShirt.java,7,64,csc324.clothes.DressShirt
XTShirt.java,7,29,csc324.clothes.TShirt
XSweater.java,7,29,csc324.clothes.Sweater
XInformalShirt.java,8,60,csc324.clothes.InformalShirt
XDressPants.java,7,33,csc324.clothes.DressPants
XShorts.java,7,28,csc324.clothes.Shorts
XPants.java,7,59,csc324.clothes.Pants
XCasualShirt.java,7,28,csc324.clothes.CasualShirt
XClothingInventory.java,9,200,csc324.clothes.ClothingInventory
XClothes.java,7,127,csc324.clothes.Clothes
XBottom.java,7,56,csc324.clothes.Bottom
END_OF_FILE
if test 576 -ne `wc -c <'csc324/clothes/clothes.map'`; then
    echo shar: \"'csc324/clothes/clothes.map'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/clothes.map'
fi
if test -f 'csc324/clothes/clothes.prj' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/clothes/clothes.prj'\"
else
echo shar: Extracting \"'csc324/clothes/clothes.prj'\" \(368 characters\)
sed "s/^X//" >'csc324/clothes/clothes.prj' <<'END_OF_FILE'
Xsun.jws.version.2
Xsun.jws.package=csc324
Xsun.jws.classname=clothes
Xsun.jws.useVisual=false
Xsun.jws.type=package
Xsun.jws.classdir=../../
Xsun.jws.options=-g
Xsun.jws.files=List
XBottom.java
XCasualShirt.java
XClothes.java
XClothingInventory.java
XDressPants.java
XDressShirt.java
XInformalShirt.java
XJeans.java
XPants.java
XShorts.java
XSweater.java
XTShirt.java
XTop.java
XEndOfList
END_OF_FILE
if test 368 -ne `wc -c <'csc324/clothes/clothes.prj'`; then
    echo shar: \"'csc324/clothes/clothes.prj'\" unpacked with wrong size!
fi
# end of 'csc324/clothes/clothes.prj'
fi
if test -f 'csc324/driver/Driver.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/driver/Driver.java'\"
else
echo shar: Extracting \"'csc324/driver/Driver.java'\" \(5834 characters\)
sed "s/^X//" >'csc324/driver/Driver.java' <<'END_OF_FILE'
Xpackage csc324.driver;
X
X// Driver: A generic command-line interface.  Created by Mary Ellen Foster,
X// modified by Paul Gries and Ray Ortigas.
X
Ximport java.io.*;
Ximport java.util.*;
Ximport csc324.clothes.*;
Ximport java.lang.reflect.*; 
X
Xpublic class Driver {
X    // Declare all static instance variables here.
X
X    // printHelp: Prints a list of possible commands.
X    public static void printHelp() {
X	// Find out what type of clothes to create.
X	System.out.println("Commands: ? (help), q (quit), " +
X			   "c (create new item), s (sell item), " +
X			   "n (count items), t (total sales), " + 
X			   "l (list items)");
X
X    }
X
X    // printList: Prints a list of the items in e, with spaces in between.
X    private static void printList( Enumeration e ) {
X	while (e.hasMoreElements()) { 
X	    System.out.print( e.nextElement() + "  " );
X	}
X	System.out.println();
X    }
X
X    // printList: Prints a numbered list of the items in e.
X    private static void printNumberedList( Enumeration e ) {
X	int i=0;
X	while (e.hasMoreElements()) { 
X	    System.out.println( "    " + i++ + " " + e.nextElement() );
X	}
X    }
X
X    // printTotalSales: Prints the total dollar amount of items sold so far
X    // from 'inventory'.
X    private static void printTotalSales( ClothingInventory inventory ) {
X	System.out.println( "Total sales: " + inventory.totalSales() );
X    }
X
X    // printListOfItems: Prints the items in 'inventory'.
X    private static void printListOfItems( ClothingInventory inventory ) {
X	System.out.println( "Current inventory: " );
X	    // Print the list of items.
X	    Vector items = inventory.getItems();
X	    printNumberedList( items.elements() );
X    }
X
X    // printNumberOfItems: Prints the number of items in 'inventory' of the
X    // type of clothing specified by the user, read from 'in'.
X    private static void printNumberOfItems( BufferedReader in,
X					    ClothingInventory inventory ) {
X	// Find out what type of clothes to count.
X	System.out.println(" Which type of clothing to count?" );
X	try {
X	    // Print the list of clothing types.
X	    Enumeration items = inventory.getAllClothingTypes();
X	    printList( items );
X		
X	    // Read in the type of clothing to sell.
X	    String s = in.readLine();
X			
X	    System.out.println(" There are " + inventory.countItemType( s ) +
X			       " items of type " + s );
X	} catch( Exception e ) {
X	    e.printStackTrace();
X	}
X    }
X
X    // createClothes: Reads the type of clothing to create from 'in', create
X    // it, and store it in 'inventory' (provided the input are valid).
X    public static void sellClothes( BufferedReader in,
X				    ClothingInventory inventory ) {
X	// Find out what type of clothes to create.
X	System.out.println(" Which piece of clothing to sell?" );
X		
X	try {
X	    // Print the list of items.
X	    Vector items = inventory.getItems();
X	    printNumberedList( items.elements() );
X		
X	    // Read in the line number of the clothing to sell.
X	    String s = in.readLine();
X	    int i = Integer.parseInt( s );
X	    Clothes c = (Clothes)items.elementAt( i );
X	    inventory.sellItem( c );
X	} catch( Exception e ) {
X	    e.printStackTrace();
X	}
X    }
X
X    // createClothes: Reads the type of clothing to create from 'in', create
X    // it, and store it in 'inventory' (provided the input are valid).
X    public static void createClothes( BufferedReader in,
X				      ClothingInventory inventory ) {
X	// Find out what type of clothes to create.
X	System.out.println("    What type of clothing to create?" );
X	System.out.print("    Choices: " );
X	Enumeration clothingTypes = inventory.getClothingTypes();
X	while ( clothingTypes.hasMoreElements() ) { 
X	    System.out.print( "  " + clothingTypes.nextElement() );
X	}
X	System.out.println();
X		
X	try {
X	    // Read in the type of clothing to create.
X	    String itemType = in.readLine();
X
X	    // Prompt for the values necessary to build the new piece of
X	    // clothing.     
X	    Hashtable attributeTable = new Hashtable();
X	    Enumeration e = inventory.attributesForItemType(itemType);
X	    while (e.hasMoreElements()) {
X		String attributeName = (String)e.nextElement();
X		System.out.print(attributeName + ": ");
X		String attributeValue = in.readLine();
X		attributeTable.put(attributeName, attributeValue);
X	    }
X
X	    // Add the piece of clothing to the inventory.
X	    inventory.addItem(itemType, attributeTable);
X
X	} catch( Exception e ) {
X	    e.printStackTrace();
X	}
X    }
X
X    // main: Reads commands and acts on them until the user enters 'q'.
X    public static void main( String args[] ) throws IOException {
X
X	// The inventory of clothes.
X	ClothingInventory inventory = new ClothingInventory();
X
X	// Create the command line input stream.
X	BufferedReader in = new BufferedReader( 
X	    new InputStreamReader( System.in ), 1 );
X
X	// cmd is the current command.
X	char cmd = '\0';
X
X	while( cmd != 'q' ) {
X
X	    // Print a prompt and read the next command.
X	    printHelp();
X	    System.out.print( "THE_GAP> " );
X	    cmd = in.readLine().charAt( 0 );
X
X
X	    // One huge, ugly "switch" statement.
X	    // Currently only handles one command, quit.
X	    switch( cmd ) {
X	    case '?':
X		// Create new clothing.
X		printHelp();
X		break;
X
X	    case 'q':
X		// Quit
X		break;
X
X	    case 'c':
X		// Create new clothing.
X		createClothes( in, inventory );
X		break;
X
X	    case 's':
X		// Sell an item of clothing.
X		sellClothes( in, inventory );
X		break;
X
X	    case 'n':
X		// Print the number of items of a particular type.
X		printNumberOfItems( in, inventory );
X		break;
X
X	    case 't':
X		// Print the total amount of money made so far.
X		printTotalSales( inventory );
X		break;
X
X	    case 'l':
X		// List the items in the inventory.
X		printListOfItems( inventory );
X		break;
X
X	    default:
X		// Otherwise, I don't understand the command.
X		System.out.println("Beeble brobble kerble mop?");
X		break;
X	    }
X	}
X    }
X}
END_OF_FILE
if test 5834 -ne `wc -c <'csc324/driver/Driver.java'`; then
    echo shar: \"'csc324/driver/Driver.java'\" unpacked with wrong size!
fi
# end of 'csc324/driver/Driver.java'
fi
if test -f 'csc324/driver/driver.map' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/driver/driver.map'\"
else
echo shar: Extracting \"'csc324/driver/driver.map'\" \(51 characters\)
sed "s/^X//" >'csc324/driver/driver.map' <<'END_OF_FILE'
XVERSION: 1
XDriver.java,11,198,csc324.driver.Driver
END_OF_FILE
if test 51 -ne `wc -c <'csc324/driver/driver.map'`; then
    echo shar: \"'csc324/driver/driver.map'\" unpacked with wrong size!
fi
# end of 'csc324/driver/driver.map'
fi
if test -f 'csc324/driver/driver.prj' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/driver/driver.prj'\"
else
echo shar: Extracting \"'csc324/driver/driver.prj'\" \(205 characters\)
sed "s/^X//" >'csc324/driver/driver.prj' <<'END_OF_FILE'
Xsun.jws.version.2
Xsun.jws.package=csc324.driver
Xsun.jws.classname=Driver
Xsun.jws.useVisual=false
Xsun.jws.type=standalone
Xsun.jws.classdir=../../
Xsun.jws.options=-g
Xsun.jws.files=List
XDriver.java
XEndOfList
END_OF_FILE
if test 205 -ne `wc -c <'csc324/driver/driver.prj'`; then
    echo shar: \"'csc324/driver/driver.prj'\" unpacked with wrong size!
fi
# end of 'csc324/driver/driver.prj'
fi
if test -f 'csc324/util/VectorManipulator.java' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/util/VectorManipulator.java'\"
else
echo shar: Extracting \"'csc324/util/VectorManipulator.java'\" \(334 characters\)
sed "s/^X//" >'csc324/util/VectorManipulator.java' <<'END_OF_FILE'
X// class VectorManipulator: a class that can manipulate Vectors.
X
Xpackage csc324.util;
X
Ximport java.util.*;
X
Xpublic class VectorManipulator {
X
X    // Add all the elements in e to v.
X    public static void addItemsToVector( Vector v, Enumeration e ) {
X	
X	while( e.hasMoreElements() ) {
X	    v.addElement( e.nextElement() );
X	}
X    }
X}
END_OF_FILE
if test 334 -ne `wc -c <'csc324/util/VectorManipulator.java'`; then
    echo shar: \"'csc324/util/VectorManipulator.java'\" unpacked with wrong size!
fi
# end of 'csc324/util/VectorManipulator.java'
fi
if test -f 'csc324/util/util.map' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/util/util.map'\"
else
echo shar: Extracting \"'csc324/util/util.map'\" \(69 characters\)
sed "s/^X//" >'csc324/util/util.map' <<'END_OF_FILE'
XVERSION: 1
XVectorManipulator.java,7,16,csc324.util.VectorManipulator
END_OF_FILE
if test 69 -ne `wc -c <'csc324/util/util.map'`; then
    echo shar: \"'csc324/util/util.map'\" unpacked with wrong size!
fi
# end of 'csc324/util/util.map'
fi
if test -f 'csc324/util/util.prj' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'csc324/util/util.prj'\"
else
echo shar: Extracting \"'csc324/util/util.prj'\" \(204 characters\)
sed "s/^X//" >'csc324/util/util.prj' <<'END_OF_FILE'
Xsun.jws.version.2
Xsun.jws.package=csc324
Xsun.jws.classname=util
Xsun.jws.useVisual=false
Xsun.jws.type=package
Xsun.jws.classdir=../../
Xsun.jws.options=-g
Xsun.jws.files=List
XVectorManipulator.java
XEndOfList
END_OF_FILE
if test 204 -ne `wc -c <'csc324/util/util.prj'`; then
    echo shar: \"'csc324/util/util.prj'\" unpacked with wrong size!
fi
# end of 'csc324/util/util.prj'
fi
echo shar: End of shell archive.
exit 0
