ADD file via upload

main
puem2gl9z 1 year ago
parent e131f48ace
commit 85314555a8

@ -0,0 +1,91 @@
package com.example.drink_order_system;
import android.util.Log;
import java.util.ArrayList;
public class Restaurant {
private int number;
private String name;
private int volume;
private String introduction;
//private int distance;
private String imagePath;
static ArrayList<Restaurant> all_restaurant = new ArrayList<>();//用于存储所有餐厅对象
//该构造函数不包含type属性用于初始化普通不包含小标题的饮品
Restaurant(String name, int volume, String introduction, String imagePath)
{
// 检查是否已存在相同名称的餐厅
boolean exists = false;
for (Restaurant r : all_restaurant) {
if (r.name.equals(name)) {
exists = true;
break;
}
}
if (!exists) {
this.number = all_restaurant.size();
this.name = name;
this.volume = volume;
this.introduction = introduction;
this.imagePath = imagePath;
all_restaurant.add(this);
Log.d("Rpic",this.imagePath);
} else {
System.out.println("餐厅 " + name + " 已存在,不再添加。");
}
}
// public int get_volume()
// {
// return volume;
// }
//
// //public int get_distance()
// {
// return distance;
// }
public String get_name()
{
return name;
}
public String get_imagePath()
{
return imagePath;
}
public String get_introduction()
{
return introduction;
}
public void set_name(String name)
{
this.name = name;
}
public int get_volume() {return volume;}
public void set_imagePath(String imagePath)
{
this.imagePath = imagePath;
}
public void set_volume(int volume)
{
this.volume = volume;
}
public void set_distance(int distance)
{
this.volume = distance;
}
public void set_Introduction(String introduction)
{
this.introduction = introduction;
}
}
Loading…
Cancel
Save