1
주어진 스캐너에서 항목을 읽음으로써 상점을 구성하려고합니다. 생성자는 itemName이 * 일 때까지 지정된 스캐너 객체에서 항목을 읽고 인벤토리에 추가해야합니다.스캐너를 검색하고 문자열을 공백으로 나누는 방법은 무엇입니까?
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){
}
}
@vishal_aim 잘 모르는 경우 – JustaBreitGuy
도움이 되나요? http://docs.oracle.com/javase/6/docs/api/java/util/Scanner.html –