请大神帮帮忙看一下

来源:3-4 自由编程

人在江湖第一个账号

2019-07-10 20:17:20

package ex;


public class Goods {

      public Goods() {

super();

// TODO Auto-generated constructor stub

}

      

      

public Goods(int id, String name, Float price, String desp) {

super();

this.id = id;

this.name = name;

this.price = price;

this.desp = desp;

}



private int id;//商品编号

      private String name;//商品名称

      private float price;//商品价格

      private String desp;//商品描述

      

public int getId() {

return id;

}



public void setId(int id) {

this.id = id;

}



public String getName() {

return name;

}



public void setName(String name) {

this.name = name;

}



public Float getPrice() {

return price;

}



public void setPrice(Float price) {

this.price = price;

}



public String getDesp() {

return desp;

}



public void setDesp(String desp) {

this.desp = desp;

}



@Override

public String toString() {

return "Goods [id=" + id + ", name=" + name + ", price=" + price + ", desp=" + desp + "]";

}

      

      public void display() {

      System.out.println("商品信息");

      }

}

http://img.mukewang.com/climg/5d25d73f0001ec5818320892.jpg

写回答

1回答

吃吃吃鱼的猫

2019-07-11

同学你好,

int,float是基本数据类型,不是类。

所以,将下图标识代码int改为Integer,float改为Float进行测试。

http://img.mukewang.com/climg/5d26a5c1000147af11290040.jpg

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

0

0 学习 · 8016 问题

查看课程