美文网首页
private String name; //定义“水果名称”

private String name; //定义“水果名称”

作者: 哈迪斯Java | 来源:发表于2023-06-12 10:00 被阅读0次

    public class Fruit //创建一个Fruit类
    {
    private String name; //定义“水果名称”
    private float price; //定义“水果价格”
    private float weight; //定义“水果重量”

    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 float getWeight() //获得“水果重量”
    {
        return weight;
    }
    public void setWeight(float weight) //设置“水果重量”
    {
        this.weight = weight;
    }
    

    }

    相关文章

      网友评论

          本文标题:private String name; //定义“水果名称”

          本文链接:https://www.haomeiwen.com/subject/laphddtx.html