日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > java >内容正文

java

JavaEE实战班第十一天

發(fā)布時(shí)間:2025/3/15 java 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JavaEE实战班第十一天 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

今天完成了任務(wù)的最后一個(gè)模塊,整個(gè)任務(wù)全部完成并可以使用。發(fā)現(xiàn)其中有很多沒(méi)學(xué)過(guò)的東西。

第一次完成這么龐大的任務(wù),上上下下封裝有的時(shí)候甚至找不到想改的模塊。而后學(xué)習(xí)了第七節(jié),對(duì)未來(lái)就業(yè)觀念有了一定的改觀。

package day09;
import java.util.Random;
import java.util.Scanner;
public class work01 {
?? ?public static Scanner input = new Scanner(System.in);
?? ?public static String[] numberArr=new String[100];
?? ?public static String[] companyArr=new String[100];
?? ?public static int[] codeArr=new int[100];
?? ?public static int index = 0;//有多少個(gè)快遞
?? ?public static Random random = new Random();
?? ?public static void main(String[] args) {
?? ??? ?while(true) {
?? ??? ?int id = startMenu();
?? ??? ?if(id==0) {
?? ??? ??? ?return;
?? ??? ?}
?? ??? ?}
?? ?}
?? ?public static int startMenu() {
?? ??? ?// 展示菜單
?? ??? ??? ??? ?System.out.println("=======歡迎使用新職課快遞柜======");
?? ??? ??? ??? ?System.out.print("請(qǐng)輸入您的身份:1快遞員 2用戶 0退出");
?? ??? ??? ??? ?int id = 0;
?? ??? ??? ??? ?do {
?? ??? ??? ??? ? id = input.nextInt();
?? ??? ??? ??? ?
?? ??? ??? ??? ?if(id==1) {//快遞員
?? ??? ??? ??? ??? ?deliverymanMenu();
?? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ?}else if(id==2) {//用戶
?? ??? ??? ??? ??? ?userMenu();
?? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ?}else if(id==0){
?? ??? ??? ??? ??? ?System.out.println("謝謝使用");
?? ??? ??? ??? ??? ?return 0;
?? ??? ??? ??? ?}else {
?? ??? ??? ??? ??? ?System.out.println("選擇有誤,請(qǐng)重新輸入");
?? ??? ??? ??? ?}
?? ??? ??? ??? ?}while(true);
?? ??? ??? ??? ?return id;
?? ?}
?? ?//--------------------------------------------------------------------------
?? ?public static void userMenu() {
?? ??? ?System.out.print("請(qǐng)輸入取件碼:");
?? ??? ?int code = input.nextInt();
?? ??? ?int codeIndex = isExist(code);
?? ??? ?if(codeIndex==-1) {
?? ??? ??? ?System.out.print("未找到快遞:");
?? ??? ?}else {
?? ??? ??? ?del(codeIndex);
?? ??? ??? ?System.out.print("取件成功:");
?? ??? ?}
?? ?}
?? ?//--------------------------------------------------------------------------
?? ?
?? ?//--------------------------------------------------------------------------
?? ?public static void deliverymanMenu() {
?? ??? ?System.out.print("請(qǐng)選擇操作:1存快遞 2刪除快遞 3修改快遞信息 4查看所有快遞");
?? ??? ?int id = input.nextInt();
?? ??? ?if(id==1){
?? ??? ??? ?saveExpress();
?? ??? ?}else if(id==2) {
?? ??? ??? ?
?? ??? ??? ?delExpress();
?? ??? ??? ?
?? ??? ?}else if(id==3) {
?? ??? ??? ?System.out.println("請(qǐng)輸入要修改的快遞信息");
?? ??? ??? ?String number = input.next();
?? ??? ??? ?int updateIndex=findByNumber(number);
?? ??? ??? ?if(updateIndex==-1) {
?? ??? ??? ??? ?System.out.println("未找到快遞");
?? ??? ??? ?}else {
?? ??? ??? ??? ?System.out.println("請(qǐng)輸入新的快遞信息");
?? ??? ??? ??? ? number = input.next();
?? ??? ??? ??? ?System.out.println("請(qǐng)輸入新的公司名稱");
?? ??? ??? ??? ?String company = input.next();
?? ??? ??? ??? ?numberArr[updateIndex]=number;
?? ??? ??? ??? ?companyArr[updateIndex]=company;
?? ??? ??? ??? ?System.out.println("修改成功");
?? ??? ??? ?}
?? ??? ?}else if(id==4) {
?? ??? ??? ?printAll();
?? ??? ?}
?? ?}
?? ?//--------------------------------------------------------------------------
?? ?public static void printAll() {
?? ??? ?System.out.println("----------這是所有的快遞信息-----------");
?? ??? ?System.out.println("快遞單號(hào)\t快遞公司\t取件碼");
?? ??? ?for(int i = 0;i<index;i++) {
?? ??? ??? ?System.out.println(numberArr[i]+"\t"+companyArr[i]+"\t"+codeArr[i]);
?? ??? ?}
?? ?}
?? ?//--------------------------------------------------------------------------
?? ?public static int findByNumber(String number) {
?? ??? ?for(int i = 0;i<index;i++) {
?? ??? ??? ?if(numberArr[i].equals(number)) {
?? ??? ??? ??? ?return i;
?? ??? ??? ?}
?? ??? ?}
?? ??? ?return -1;
?? ?}
?? ?//--------------------------------------------------------------------------
?? ?public static void ?saveExpress() {
?? ??? ?System.out.println("請(qǐng)輸入快遞單號(hào)");
?? ??? ?String number=input.next();
?? ??? ?System.out.println("請(qǐng)輸入公司名稱");
?? ??? ?String company=input.next();
?? ??? ?int code =0;?
?? ??? ?numberArr[index]=number;
?? ??? ?companyArr[index]=company;
?? ??? ?do {
?? ??? ??? ?code =random.nextInt(900)+100;
?? ??? ?}while(isExist(code)!=-1);
?? ??? ?codeArr[index]=code;
?? ??? ?index++;
?? ??? ?System.out.println("取件碼是:"+code);
?? ?}
//--------------------------------------------------------------------------
public static void delExpress() {
?? ?System.out.println("請(qǐng)輸入要?jiǎng)h除的快遞單號(hào)");
?? ?String number=input.next();
?? ?int delIndex=findByNumber(number);
?? ?if(delIndex==-1) {
?? ??? ?System.out.println("未找到快遞");
?? ?}else {
?? ??? ?//刪除
?? ??? ?del(delIndex);
?? ??? ?System.out.println("刪除成功");}
?? ?}
//--------------------------------------------------------------------------
?? ?public static void del(int delIndex) {
?? ??? ?if(delIndex!=numberArr.length-1) {
?? ??? ??? ?
?? ??? ??? ?for(int i = delIndex;i<index;i++) {
?? ??? ??? ??? ?numberArr[i]=numberArr[i+1];
?? ??? ??? ??? ?companyArr[i]=companyArr[i+1];
?? ??? ??? ??? ?codeArr[i]=codeArr[i+1];
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ?}
?? ??? ?index--;
?? ?}
//--------------------------------------------------------------------------
?? ?public static int isExist(int code) {
?? ??? ?for(int i = 0;i<index;i++) {
?? ??? ??? ?if(codeArr[i]==code) {
?? ??? ??? ??? ?return i;
?? ??? ??? ?}
?? ??? ?}
?? ??? ?return -1;
?? ?
?? ?}
}

總結(jié)

以上是生活随笔為你收集整理的JavaEE实战班第十一天的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。