diff --git a/Drinks.java b/Drinks.java new file mode 100644 index 0000000..c7dbb93 --- /dev/null +++ b/Drinks.java @@ -0,0 +1,96 @@ +package com.example.drink_order_system; + +import android.util.Log; + +import java.util.ArrayList; + +public class Drinks { + private int number; + private static int counter = 0; + private String name; + private String type; + private float price; + private String introduction; + //private int ImageResId; + private String imagePath; + static ArrayList all_drinks = new ArrayList<>();//用于存储所有饮品对象 + + //该构造函数包含type这个属性,用于初始化包含类别小标题的饮品,即每个类别中的第一个饮品 + Drinks(String name, String type, float price, String introduction, String imagePath) + { + this.number = ++counter; + this.name = name; + this.type = type; + this.price = price; + this.introduction = introduction; + this. imagePath = imagePath; + Log.i("number",String.valueOf(number)); + } + + + Drinks(int i){ + this.number = i-1; + Drinks temp = all_drinks.get(i-1); + this.name = temp.name; + this.type = temp.type; + this.price = temp.price; + this.introduction = temp.introduction; + this.imagePath = temp.imagePath; + } + public Drinks() { + this.number = counter++; + Log.i("number",String.valueOf(number)); + } + public int get_number() + { + return number; + } + + public String get_name() + { + return name; + } + + public String get_type() + { + return type; + } + + public float get_price() { return price;} + + public String get_introduction() + { + return introduction; + } + public String get_imagePath() + { + return imagePath; + } + public void set_imagePath(String imagePath) + { + this.imagePath = imagePath; + } + //public int getImageResId(){return ImageResId;} + + public void set_name(String name) + { + this.name = name; + } + + public void set_type(String type) + { + this.type = type; + } + + public void set_price(float price) + { + this.price = price; + } + + public void set_Introduction(String introduction) + { + this.introduction = introduction; + } + + //public void setImageResId(int id){this.ImageResId = id;} +}