亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

不同于老師說的結構,但實現同樣效果,不知道兩種方法有什么區別

每本書創建成單獨類調用

package com.xiaohongshu;


import java.util.Scanner;



public class Initail {


public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("書庫中的圖書目錄:");

System.out.println("1.《紅樓夢》");

System.out.println("2.《三國演義》");

System.out.println("3.《水滸傳》");

? ? ? ? System.out.println("4.《西游記》");

? ? ? ??

? ? ? ? while(true) {

? ? ? ? System.out.println("請輸入圖書的編號或名字:");

? ? ? ? Scanner input=new Scanner(System.in);

? ? ? ? String score=input.next();

? ? ? ? switch (score) {

case "1" :

case "紅樓夢":

book hello=new HongLouMeng();

? ? ? ? hello.name();

? ? ? ? hello.category();

? ? ? ? hello.author();

? ? ? ? break;

case "2":

case "三國演義":

book hello2=new SanGuoYanYi();

? ? ? ? hello2.name();

? ? ? ? hello2.category();

? ? ? ? hello2.author();

? ? ? ? break;

case "3":

case "水滸傳":

book hello3=new ShuiHuZhuan();

? ? ? ? hello3.name();

? ? ? ? hello3.category();

? ? ? ? hello3.author();

? ? ? ? break;

case "4":

case "西游記":

book hello4=new SanGuoYanYi();

? ? ? ? hello4.name();

? ? ? ? hello4.category();

? ? ? ? hello4.author();

? ? ? ? break;


default:

System.out.println("輸入錯誤,請重新輸入!");

continue;

}

? ? ? ?

//? ? ? ??

? ? ? ??

? ? ? ? }

}

}


正在回答

1 回答

當書本數量很多的時候,一個個創建類就麻煩了

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

不同于老師說的結構,但實現同樣效果,不知道兩種方法有什么區別

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號