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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何更新數(shù)組列表中的用戶輸入?

如何更新數(shù)組列表中的用戶輸入?

暮色呼如 2021-05-14 15:14:20
因此,我正在為汽車經(jīng)銷商制定程序,這是我班的最后一個項目。目前,我說我已經(jīng)完成了75%,但是我在弄清楚如何更新數(shù)組列表中的用戶輸入時遇到了麻煩。因此,每個陣列列表插槽均包含汽車的年份,品牌,型號,顏色和行駛里程。我可以添加新車,可以移除車,并且可以退出程序。我嘗試了許多事情,讀了許多論文,博客,論壇和我的課堂書籍,但是它總是隨著程序員的輸入而更新。package carDealer;import java.util.ArrayList;import java.util.Scanner;public class VehicleInformation {public static void main(String [] args) {    Scanner scnr = new Scanner(System.in);    ArrayList<VehicleInventory> car = new ArrayList<VehicleInventory>();    String userInput = "-";    while (!userInput.equals("q")) {        System.out.println("Commands: 'a' to add, 'd' to delete, 'e' to edit, 'q' to quit");        userInput = scnr.next();        if (userInput.equals("a")) {            System.out.println("Year: ");            int year = scnr.nextInt();            System.out.println("Make: ");            String make = scnr.next();            System.out.println("Model: ");            String model = scnr.next();            System.out.println("Color: ");            String color = scnr.next();            System.out.println("Mileage: ");            int mileage = scnr.nextInt();            VehicleInventory userCar = new VehicleInventory();                  userCar.setMake(make);            userCar.setModel(model);            userCar.setYear(year);            userCar.setColor(color);            userCar.setMileage(mileage);            userCar.print();            addCar(car, userCar);        }        if (userInput.equals("d")) {            for (int i = 0; i < car.size(); ++i) {                System.out.print((i + 1) + " ");                car.get(i).print();            }            System.out.println("List number: ");            int userNum = scnr.nextInt();            car.remove(userNum - 1);            System.out.println("count: " + car.size());        }        if (userInput.equals("e")) {            for (int i = 0; i < car.size(); ++i) {                System.out.print((i + 1) + " ");                car.get(i).print();            }
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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