I am having problem with my project.
There are couple extended files but I gonna keep it short here.
all file contain the imports and the right heading.
There are:
main file - contain main method, there is a Database variable
Given file. Cant change this.
Dont know what the last two lines do, beside it is used to sort Warning: Spoiler! (Click to show)
Database file - the Database has an Item array (might do arraylist if I get the rest of the code running in time.)
Need help with this Warning: Spoiler! (Click to show)
Item file - the abstract class Warning: Spoiler! (Click to show)
Food file - food class that is an extend of the Item class Warning: Spoiler! (Click to show)
Edited by TLCH723 - 6/27/12 at 7:39am
There are couple extended files but I gonna keep it short here.
all file contain the imports and the right heading.
There are:
main file - contain main method, there is a Database variable
Given file. Cant change this.
Dont know what the last two lines do, beside it is used to sort Warning: Spoiler! (Click to show)
Code:
ComparatorChain chain=new ComparatorChain();
Datebase myList=new Database();
myList.add(new Food("Fruit","Apple","Green");
Collections.sort(myList.item);
chain.addComparator(new sortByName());
Database file - the Database has an Item array (might do arraylist if I get the rest of the code running in time.)
Need help with this Warning: Spoiler! (Click to show)
Code:
private Item[] item;
private int count=0;
public Datebase()
{item=new Item[100];}
public void add(Item input){
item[count]=input;count++
}
Item file - the abstract class Warning: Spoiler! (Click to show)
Code:
private String type;
public Item(String inputType)
{type=inputType;}
public void setType(String inputType)
{type=inputType;}
public String readType()
{return type;}
Food file - food class that is an extend of the Item class Warning: Spoiler! (Click to show)
Code:
private String type, name,color;
public Food(String inputType, String inputName,inputColor)
{type=inputType;
name=inputName;
color=inputColor;}
// there is a setName, readName, setColor, readColor here but not written to keep this shorter.
public String toString()
{ return String.format("%s\t%s\t%s",readType(),readName(),readColor());}
Edited by TLCH723 - 6/27/12 at 7:39am






