请问哪里出错了,该怎么修改,以及建议的地方。。。不胜感激
import java.util.Scanner;
class Store{
private String name;
private double size;
private double price;
private String pz;
private int have;
public Store(){
}
public void setName(String name)
{
this.name = name;
}
public void setSize(double size)
{
this.size = size;
}
public void setPrice(double price)
{
this.price = price;
}
public void setPz(String pz)
{
this.pz = pz;
}
public void setHave(int have)
{
this.have = have;
}
public String getName()
{
return name;
}
public double getSize()
{
return size;
}
public double getPrice()
{
return price;
}
public String getPz()
{
return pz;
}
public int getHave()
{
return have;
}
}
public class test {
public static void main(String[] args){
Store[] store;
store = creatStore();
printStore(store);
}
public static Store[] creatStore(){
Store[] store = new Store[3];
Scanner input = new Scanner(System.in);
for(int i=0; i<3; i++)
{
String name;
double size;
double price;
String pz;
int have;
name = input.nextLine();
size = input.nextDouble();
price = input.nextInt();
pz = input.nextLine();
have = input.nextInt();
store[i].setName(name);
store[i].setSize(size);
store[i].setPrice(price);
store[i].setPz(pz);
store[i].setHave(have);
}
return store;
}
public static void printStore(Store[] store){
System.out.println("品牌型号\t 尺寸\t 价格\t 配置\t 库存");
for(int i=0; i<3; i++)
{
System.out.println(store[i].getName()+"\t"+store[i].getSize()+"\t"+store[i].getPrice()+"\t"+store[i].getPz()+"\t"+store[i].getHave());
}
}
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.