. Java Cart . Java Cart ItemType java
Java Cart ItemType java
package cart;
//ItemType - used as part of item,
//must be created to determine how to build an item,
//so is built first then passed into the item's constructor
//author - Lawrence Truett - FluffyCat.com
//date - August 4, 2003 - San Diego, CA
public class ItemType {
private char[] type = new char[5];
ItemType(String typeString) {
setType(typeString);
}
ItemType(char[] charArrayIn) {
setType(charArrayIn);
}
public char[] getType() {return type;}
public char getTypeChar0() {return type[0];}
public char getTypeChar1() {return type[1];}
public char getTypeChar2() {return type[2];}
public char getTypeChar3() {return type[3];}
public char getTypeChar4() {return type[4];}
void setType(String typeIn) {
this.type[0] = typeIn.charAt(0);
this.type[1] = typeIn.charAt(1);
this.type[2] = typeIn.charAt(2);
this.type[3] = typeIn.charAt(3);
this.type[4] = typeIn.charAt(4);
}
void setType(char[] typeIn) {
this.type = typeIn;
}
public String toString() {return type[0] + " " +
type[1] + " " +
type[2] + " " +
type[3] + " " +
type[4];}
}
download source, use right-click and "Save Target As..." to save with a .java extension.
| Comments |
| Sign In |
| to add the first comment for Java Cart ItemType java. |