jsp第九次作业

1.
package book;

import java.util.ArrayList;
import java.util.List;

public class Book {
    private String id;
    private String name;
    private double price;
    public String getId() {
        return id;
    }
    public void setId(String 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;
    }
    public Book(String id, String name, double price) {
        super();
        this.id = id;
        this.name = name;
        this.price = price;
    }
    public Book() {
package book;

public class bookTest {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Book b1=new Book("a","aa",10);
        Book b2=new Book("b","bb",20);
        Book b3=new Book("c","cc",30);
        Book b4=new Book("d","dd",40);
        Book b=new Book();
        b.add(b1);
        b.add(b2);
        b.add(b3);
        b.showAll();
        b.set(b4, 0);
        System.out.println("==============");
        b.showAll();
        System.out.println("==============");
        b.remove(b4);
        b.showAll();

    }

}

  

2.

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
    
    <title>My JSP 'd1.jsp' starting page</title>

  </head>
  <%@ page import="book.Book" %>
  
  <body>
    <%
  List<Book> list=new ArrayList<Book>();
  Book b1=new Book();
  b1.setId("a");
  b1.setName("中华小当家");
  b1.setPrice(10);
  Book b2=new Book();
  b2.setId("b");
  b2.setName("三国演义");
  b2.setPrice(20);
  list.add(b1);
  list.add(b2);
  for(int i=0;i<list.size();i++){
            out.print("ID:"+list.get(i).getId()+",NAME:"+list.get(i).getName()+",PRICE:"+list.get(i).getPrice()+"<br>");
        }
   %>
  </body>
</html>

  

3.

CREATE TABLE `book`  (
  `id` int(11) NOT NULL,
  `name` varchar(255),
  `price` double(10),
)
insert into book values(1,'嘻嘻哈哈',50)
update book set price = 18.8 where price > 20
select * from book
select * from book where price > 10
delete from book where name = '嘻嘻哈哈'

  

 

posted @ 2022-05-01 13:55  李芊  阅读(30)  评论(0编辑  收藏  举报