特定のスキャナーからアイテムを読み取ってストアを構築しようとしています。コンストラクターは、指定されたスキャナーオブジェクトからアイテムを繰り返し(アイテム名が*になるまで)読み取り、インベントリに追加する必要があります。
BreadLoaf 2.75 25
このような文字列を「Breadloaf」、「2.75」、「25」に分割する必要があります。次に、次の行に移動して、「*」と表示されるまで同じことを行います。
public class Store {
private ArrayList<Item> inventory;
// CONSTRUCTORS
/*
* Constructs a store without any items in its inventory.
*/
public Store() {
}
/*
* Constructs a store by reading items from a given Scanner. The constructor
* must repeatedly (until item name is *) read items from the given scanner
* object and add it to its inventory. Here is an example of the data (that
* has three items) that could be entered for reading from the supplied
* scanner:
*/
public Store(Scanner keyboard) {
while(keyboard != null){
}
}