第九周作业
1.
package ManageBook;
public class Book {
private int id;
private String name;
private double price;
public Book() {
}
public Book(int id, String name, double price) {
super();
this.id = id;
this.name = name;
this.price = price;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
package ManageBook; import java.util.List; public class Menu { /** * @param args */ List<Book>list; public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("menu"); System.out.println("1 --- add ---"); System.out.println("2 --- delete ---"); System.out.println("3 --- modify ---"); System.out.println("4 --- query ---"); System.out.println("6 --- exit ---"); } }
3.在MySQL中创建Book表,里面id,name,price,
用命令实现,
添加一个图书,
根据名称删除图书,
把所有名称是“我”开头的图书删除,
删除全部图书,
把20元以上的图书价格都修改为18.8,
查看全部图书,
查看价格高于10块钱的全部图书
建表
create table books{ id int not null, name varchar() price decimal, primary key(id) }; 添加2个图书 insert into Book(id,name,price)values(1,"你是我的荣耀",100); insert into Book(id,name,price)values(2,"我在未来等你",15); 把20元以上的图书价格都修改为18.8, update book set price=18.8 where price>20; 查看全部图书 select *from book; 查看价格高于10块的全部图书 select * from book where price>10; 把所有名称是“我”开头的图书删除 delete from book where name like '我%'; 删除全部图书
delete from book;