qustliumeng 2016-09-05 03:21 采纳率: 0%
浏览 2520

java 测试类中如何调用scanner

class Phone{
private double weight;
private double length;
private double width;
private double high;
private int worth;
private String brand;
private String version;
private String monitor;
private String net;
private int ram;
public double getWeight(){
return weight;
}
public void setWeight(double weight){
this.weight=weight;
}
public double getLength(){
return length;
}
public void setLength(double length){
this.length=length;
}
public double getWidth(){
return width;
}
public void setWidth(double width){
this.width=width;
}
public double getHigh(){
return high;
}
public void setHigh(double high){
this.high=high;
}
public int getWorth(){
return worth;
}
public void setWorth(int worth){
this.worth=worth;
}
public String getBrand(){
return brand;
}
public void setBrand(String brand){
this.brand=brand;
}
public String getVersion(){
return version;
}
public void setVersion(String version){
this.version=version;

}
public String getMonitor(){
    return monitor;
}
public void setMonitor(String monitor){
    this.monitor=monitor;

}
public String getNet(){
    return net;
}
public void setNet(String net){
    this.net=net;

}
public int getRam(){
    return ram;
}
public void setRam(int ram){
    this.ram=ram;
}

public void show(){
    System.out.println("品牌:"+brand);
    System.out.println("版本:"+version);
    System.out.println("长度:"+length+"mm");
    System.out.println("宽度:"+width+"mm");
    System.out.println("高度:"+high+"mm");
    System.out.println("重量:"+weight+"g");
    System.out.println("价格:"+worth+"¥");
    System.out.println("主屏参数:"+monitor);
    System.out.println("网络制式:"+net);
    System.out.println("内存容量:"+ram+"M");

}

}
import.java.util.*;//编译在这里报错,缺少class interface或enum
class Nokia{
public static void main(String[]agrs){
Phone p=new Phone();
p.setBrand("Nokia");
p.setVersion("7210C Series 40 5th Edition, Feature Pack 1");
p.setWorth(850);
p.setLength(106.0);
p.setWidth(45.1);
p.setHigh(10.6);
p.setWeight(88.8);
p.setMonitor("26万色,QVGA,240×320像素,2.0英寸");
p.setNet("GSM 900/1800/1900,EDGE");
p.setRam(30);
p.show();
}
}

  • 写回答

7条回答 默认 最新

  • qq.8693 2016-09-05 03:27
    关注

    import java.util.Scanner import后边不能加点

    评论

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效