吃货联盟系统简单实现(对象+数组)

 

package KindMethod1;

//              菜单

public class Food {
    private String food;        //餐品信息
    private double price;        //价格
    private int like;            //点赞数
    
    public Food() {
        super();
    }
    public Food(String food, double price,int like) {
        super();
        this.food = food;
        this.price = price;
        this.like=like;
    }
    public String getFood() {
        return food;
    }
    public void setFood(String food) {
        this.food = food;
    }
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public int getLike() {
        return like;
    }
    public void setLike(int like) {
        this.like = like;
    }
}

package KindMethod1;

//        步骤具体实现
public class Method{
	private NewMessage[] newmessage;		//个人信息数组
	Food[] food;					//菜单数组
	int num=0;
	int num1=0;
	
//	初始化信息数组长度
	public Method(int num){
		newmessage=new NewMessage[num];
		food = new Food[num];
	}
	
	public void addArray(Food foods){
			food[num1++]=foods;
	}
	
//	添加信息,添加成功显示true,否则显示false
	public boolean addArray(NewMessage newmessag){
		if(num>newmessage.length){
			return false;
		}else{
			newmessage[num++]=newmessag;
			return true;
		}
	}
//	显示所有的信息
	public NewMessage[] showAll(){
		NewMessage[] newmess = new NewMessage[num];
		for(int i = 0;i<num;i++){
			newmess[i]=newmessage[i];
		}
		return newmess;
	}
//	显示菜单信息
	public Food[] show(){
		Food[] food1 =new Food[num1];
		for(int i = 0;i<num1;i++){
			food1[i]=food[i];
		}
		return food1;
	}
//	签收订单,成功返回true,否则返回flase
	public boolean sign(int i){
		if(i<0||i>num){
			return false;
		}else if(newm
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

「已注销」

老板大气,I am happy

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值