package SY13; public static void addwarehouse { while(true){ System.out.print("是否要录入商品?(y/n:)"); Scanner w = new Scanner(System.in); String s = w.next(); if (!s.equalsIgnoreCase("N")){ Scanner scl=new scanner(System.in); System.out.print("请输入商品的编号:"); String gid=scl.next(); System.out.print("请输入商品的名称:"); String name=scl.next(); System.out.print("请输入商品的颜色:"); String color=scl.next(); System.out.print("请输入商品的价格:"); int p=scl.nextInt(); System.out.print("请输入商品的数量:"); int n=scl.nextInt(); c.add(new Phone(gid,name,color,p,n)) } break; } }检测错误并修正
时间: 2024-01-10 18:02:38 浏览: 72
catkin_package.xml - ROS Wiki.pdf
package SY13;
import java.util.Scanner;
public class Warehouse {
public static void addWarehouse() {
while (true) {
System.out.print("是否要录入商品?(y/n): ");
Scanner w = new Scanner(System.in);
String s = w.next();
if (!s.equalsIgnoreCase("n")) {
Scanner scl = new Scanner(System.in);
System.out.print("请输入商品的编号:");
String gid = scl.next();
System.out.print("请输入商品的名称:");
String name = scl.next();
System.out.print("请输入商品的颜色:");
String color = scl.next();
System.out.print("请输入商品的价格:");
int p = scl.nextInt();
System.out.print("请输入商品的数量:");
int n = scl.nextInt();
c.add(new Phone(gid, name, color, p, n));
} else {
break;
}
}
}
}
注:上面代码中的 `Phone` 类需要根据具体情况定义。
阅读全文