栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

学生借书信息统计

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

学生借书信息统计

书信息类

package test0328;

public class Book {
    private String title;
    private double price;
    public Book() {
        
    }
    public Book(String title,double price) {
        this.title = title;
        this.price = price;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getTitle() {
        return this.title;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public double getPrice() {
        return this.price;
    }

}

测试类

package test0328;

import java.util.Scanner;

public class Student {
    private String name;
    private int birth;
    private Book[]book = new Book[10];
    public Student() {
        
    }
    public Student(String name) {
        this.name = name;
    }
    public Student(String name,int birth,Book book) {
        this.name = name;
        this.birth = birth;
        this.book[0] = book;
        
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return this.name;
    }
    public void setBook(Book[]book) {
        this.book = book;
    }
    public Book[] getBook() {
        return this.book;
    }
    public void setBirth(int birth) {
        this.birth = birth;
    }
    public int setBirth() {
        return this.birth;
    }
    public static void main(String[]args) {
        Scanner s = new Scanner(System.in);
        Book[] book = new Book[2];
        book[0] = new Book();
        book[0].setTitle("小王子");
        book[0].setPrice(28.8);
        Student student = new Student("胡梦杰",20030406,book[0]);
        book[1] = new Book();
        book[1].setTitle("红楼梦");
        book[1].setPrice(88.8);
        student.setBook(book);
        System.out.println("借书人的姓名是:"+student.name+"n"+"出生日期为"+student.birth+"n"+"借书的详细信息:");
        for(int i=0;i             System.out.println(book[i].getTitle()+book[i].getPrice());
        }
        s.close();        
    }

}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/786025.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号