You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}
}