Day7 数据库的简单使用 java描述继续~

在这里插入图片描述

package com.yqm.day6SK;

public class Customer {

	private String name;
	private String mobile;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	

}

package com.yqm.day6SK;

import java.util.Date;

public class Order {
	private Product product;
	
	private Warehouse warehouse;
	
	//创建订单的时间
		private Date createDate;
		//预约的时间
		private Date bookDate;
		
		private String type;
		
		public String getType() {
			return type;
		}

		public void setType(String type) {
			this.type = type;
		}

		public Order(Product a, Warehouse b, Date c,String type) {
			this.createDate=new Date();
			this.product=a;
			this.warehouse=b;
			this.bookDate=c;
			this.type=type;
		}
		
		public Product getProduct() {
			return product;
		}
		public void setProduct(Product product) {
			this.product = product;
		}
		public Warehouse getWarehouse() {
			return warehouse;
		}
		public void setWarehouse(Warehouse warehouse) {
			this.warehouse = warehouse;
		}
		public Date getCreateDate() {
			return createDate;
		}
		public void setCreateDate(Date createDate) {
			this.createDate = createDate;
		}
		public Date getBookDate() {
			return bookDate;
		}
		public void setBookDate(Date bookDate) {
			this.bookDate = bookDate;
		}
		
		
	
}

package com.yqm.day6SK;

public class Product {
	//产品的名字
	private String name;
	//产品的价格
	private String price;
	//产品的类型
	private String type;
	
	private Customer customer;
	
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Product(String name, String price, String type) {
		this.name=name;
		this.price=price;
		this.type=type;
	} 
	
	public Product() {
		// TODO Auto-generated constructor stub
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	} 
}

package com.yqm.day6SK;

public class Warehouse {
	private String name;
	private String address;
	private String mobile;
	private String time;
	
	public String getTime() {
		return time;
	}
	public void setTime(String time, String time1) {
		this.time = time;
		this.time = time1;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
}

package com.yqm.day6SK;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import com.yqm.day6SK.Order;

public class OrderController {
	ArrayList orderlist=new ArrayList();
	
	public boolean book(Product target,Date c, String type) {
		boolean aa=false;
		Warehouse warehouse=new Warehouse();
		warehouse.setAddress("上海市临港新城上海电机学院");
		warehouse.setName("电机学院仓库1");
		warehouse.setMobile("123123123");
		warehouse.setTime("08:00","18:00");
		if(orderlist.size()<10){
			Order order=new Order( target, warehouse,  c,  type);
			orderlist.add(order);
			aa=true;
		}else{
			System.out.println("预约已满");
		}
		return aa;
	}
	
	//完成订单
	public boolean finishOder(Order order){
		return orderlist.remove(order);
	}
	
	
	//查看门店所有订单
	public ArrayList showAll(){
			return orderlist;
		}
	
	//打印所有订单
		public void print(){
				for(int i=0;i<orderlist.size();i++){
					Order x=(Order) orderlist.get(i);
					System.out.println(x.getProduct().getCustomer().getName());
					System.out.println("下单时间:"+x.getCreateDate());
					System.out.println("产品:"+x.getProduct().getName()+x.getProduct().getPrice()+x.getProduct().getType());
					System.out.println("预约时间:"+x.getBookDate());
					System.out.println("类型:"+x.getType());
				}
			}


		
		
		
		
		
	}
	
	
	



package com.yqm.day6SK;

import java.util.Date;

public class Test {


	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Customer c=new Customer();
		c.setMobile("123456");
		c.setName("顾客 Y先生");
		Product ar=new Product();
		ar.setCustomer(c);
		ar.setName("鱼肝油");
		ar.setPrice("100rmb");
		ar.setType("保健品");
		Date d=new Date(119,7,13,15,0,0);
		OrderController ordercontroller=new OrderController();
		ordercontroller.book(ar, d, "存货");
		ordercontroller.print();
		

	}

}

还是没法完全做出来,还有很多不会的地方·····比如想做个时间的比较方法,无从下手= = 结对没做·······

接下来做了数据库的几个简单操作

use java10;

create table student(
	name varchar(30),
	id int,
	score double,
	classname varchar(10)	
);
-- 查询数据
select * from user;
-- 插入条数据
insert into user (name,pwd)
values('小张','999');
-- 条件查询
select * from user where name='小红';
-- 修改
update user set pwd='5555' where name='小红';
-- 删除
delete from user where name='小张';




以及建表之类的操作

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值