class Recipe{
String name;
int numberOfInstructions,numberOfIngredients;
String[] instructions=new String[5];
String[] ingredients=new String[5];
Recipe(){
name={"coke-chiken"};
}
public String getInstructions(){
for(int i=0;i<5;i++)
{instructions[i]=""}
}
public String getIngredients(){}
public String toString(){
return
}
public boolean equals(Object obj){}
}
public class Cookbook{}
这个题的题目是Recipe class写Recipe的name, numberOfInstructions(造作指南个数),numberOfIngredients(配料个数),instructions(操作指南),ingredients(配方)定义为字符串数组,在Cookbook class类里 用public void addRecipe(把Recipe加进list里) ,
public Recipe findRecipe(基于Recipe name找出Recipe), public void removeRecipe(删除Recipe单个),public string toString()三个方法
可以自己加Constructor和method.
String name;
int numberOfInstructions,numberOfIngredients;
String[] instructions=new String[5];
String[] ingredients=new String[5];
Recipe(){
name={"coke-chiken"};
}
public String getInstructions(){
for(int i=0;i<5;i++)
{instructions[i]=""}
}
public String getIngredients(){}
public String toString(){
return
}
public boolean equals(Object obj){}
}
public class Cookbook{}
这个题的题目是Recipe class写Recipe的name, numberOfInstructions(造作指南个数),numberOfIngredients(配料个数),instructions(操作指南),ingredients(配方)定义为字符串数组,在Cookbook class类里 用public void addRecipe(把Recipe加进list里) ,
public Recipe findRecipe(基于Recipe name找出Recipe), public void removeRecipe(删除Recipe单个),public string toString()三个方法
可以自己加Constructor和method.
Develop a program that implements(实现) a cookbook. We are providing(提供) a general description(种类) of the classes associated(关联) with this design. Feel free to add any methods/data members (成员)you understand are necessary. Try to practice the following concepts as you develop the implementation:
One-dimensional array of objects(一维数组对象)
get/set methods for classes(给类设置方法)
private vs. public access specifiers(private和public接口说明)
Passing primitives and objects as parameters(原始和对象参数传递)
I. Recipe(食谱) class - represents a cooking recipe.(代表烹饪食谱)
---------------
data members:
1. name - name associated with the recipe (e.g. "YuXiangRouSi")
2. Instructions(操作指南) - an array of String objects where each entry represents one
instruction associated with the recipe.
3. numberOfInstructions - integer representing the number of instructions(操作指南的数量)
4. Ingredients(配料) - an array of String objects where each entry represents an ingredient(字符串数组表示参加的配料)
5. numberOfIngredients - integer representing the number of ingredientsmethods:
1. Appropriate(适当的) constructor
2. get/set methods you understand are necessary
3. toString() method
4. public boolean equals(Object obj) --- to compare two Recipes and return true if the two Recipes have same contents.(比较两个食谱如果内容相等返回真)
II. Cookbook - represents the collection of recipes(代表收集的食谱)
-------------
data members:
1. listOfRecipes - an ArrayList of Recipe objects
2. numberOfRecipes - an integer representing the number of recipes(代表int型recipes数量)
methods:
1. Appropriate(适当的) constructor
2. get/set methods you understand are necessary
3. public void addRecipe (Recipe r) - adds the recipe to the list.
You must keep the recipes ordered(安排好) by recipe name.
4. public Recipe findRecipe( String recipeName) - locates(找出) a recipe based on a recipe name.
5. public void removeRecipe(String name) - deletes a recipe from the cookbook.
6. public string toString( ) - implement the appropriate toString method(实施适当的toString()方法)
7. main - write a main method that tests your class and show how your methods work.