Java 项目
public ArrayShoppingList()
{
// initialise instance variables
super();
}
//public void addItem(int itemPosition,String item){
// super.add(itemPosition,item);
// }
public void addItem(){
System.out.println("Please enter the item you wish to enter into the shopping
List");
Scanner reader1 = new Scanner(System.in);
String item = reader1.next();
super.add(super.size(),item);
}
public void getPosition(){
System.out.println("Please enter the item name that you wish to find
theposition of");
Scanner reader1 = new Scanner(System.in);
String item = reader1.next();
super.indexOf(item);
}
public void removeItem(){
System.out.println("Please enter the item number that you wish to remove");
Scanner reader1 = new Scanner(System.in);
String item = reader1.next();
int itemIndex = super.indexOf(item);
super.remove(itemIndex);
}
我想知道如何在要求用户输入的测试类中测试这些方法。这些方法从 ArrayLinearList 调用其他方法并传递用户输入的数据。我想创建代码来模拟用户可能输入的内容。