第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

借書系統(tǒng)整個(gè)流程完善

標(biāo)簽:
Java

package www.imooc.book;

import java.util.Scanner;
import java.util.zip.Inflater;

public class User {
boolean fale = true;
String whatis= ("请问您是否需要租书?\t1:是\t2:否");
String bookis= ("请输入您需要借用的书籍。\t1:序号\t2:书名");
String bookid=("请输入您需要借用的书籍序号");
public Books [] books = {new Books(1, "红楼梦"),
new Books(2, "西游记"),
new Books(3, "水浒传"),
new Books(4, "金瓶梅"),
new Books(5, "悟空传"),
new Books(6, "第一次亲密接触"),
new Books(7, "福尔摩斯"),
new Books(8, "大话西游"),
new Books(9, "水煮三国"),
new Books(10, "java"),
new Books(11, "android"),
new Books(12, "我爱的人"),
};
Scanner uScanner = new Scanner(System.in);
public void JieMian() {
System.out.println("****");
System.out.println("欢迎使用温州图书馆的租书系统");
System.out.println(whatis);
int s1 = uScanner.nextInt();
if (s1==1) {
while (fale) {
System.out.println("目前存在的书籍如下");
System.out.println("序号\t"+"书名");
for(int i = 0 ;i<books.length;i++) {
System.out.println(books[i].toString());
}
this.jinruxitong();
this.bookadd();
}
}else {
System.out.println("谢谢您的光临,再见!");
System.exit(0);
}
}
public void jinruxitong() {
while (fale) {
System.out.println("请问您需要用何种方式借书\t1:序号\t2:书名");
int s2 = uScanner.nextInt();
if (s2==1) {
try {
this.BookId();
fale = false;
} catch (NumException e) {
System.out.println(e.getMessage());
}
}else if (s2==2) {
try {
this.BookName();
fale = false;
}
catch (NameException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}
}else{
System.out.println("序号输入错误!");
}
}
}

public void BookId() throws NumException {
    System.out.println("请输入图书序号!");
    int bookid = uScanner.nextInt();
    if(bookid>0&&bookid<=books.length+1) {
        for(int i = 0;i<books.length;i++) {
            if (bookid==books[i].getId()) {
                System.out.println("借用的图书如下:");
                System.out.println(books[i].getName());
                }
            }
    }else {
        throw new NumException("图书不存在!");
    }
}
public void BookName() throws NameException{
    System.out.println("请输入图书名称!");
    String bookname = uScanner.next();
    boolean book = true;
    for(int i = 0;i<books.length;i++) {
        if (books[i].getName().equals(bookname)) {
            book = true;    
            }else {
            book= false;
            }
        }
    if (book) {
        System.out.println("借用的图书如下:");
        System.out.println(bookname);
    }else {
        throw new NameException("图书不存在!");
    }
}

public void bookadd() {
    System.out.println("请问是否还需要借书\t1:是\t2:否");
    int bookadd = uScanner.nextInt();
    if (bookadd==1) {
        fale=true;
    }else {
        fale=false;         
        System.out.println("租书结束,谢谢使用!");
        System.exit(0);
    }
}
public void KongZhi() {
    this.JieMian(); }

}

package www.imooc.book;

public class Book {
private int id;
private String name;
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;
}
}
package www.imooc.book;

public class Books extends Book{
public Books(int id,String name) {
this.setId(id);
this.setName(name);
}
@Override
public String toString() {
// TODO Auto-generated method stub
return super.getId()+":\t"+super.getName();
}
}
package www.imooc.book;

public class NameException extends Exception{
public NameException() {
}
public NameException(String text) {
super(text);
}
}
package www.imooc.book;

public class NumException extends Exception{
public NumException() {}
public NumException(String text) {
super(text);
}
}
package www.imooc.book;

public class Test {
public static void main(String[] args) {
User user = new User();
user.KongZhi();
}
}

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消