商品管理

package com.company;

import java.util.Scanner;

/*

* 商品管理員* */

public class ArticleManage {

// 創(chuàng)建一個商品集合(倉庫) 實例

? ? ArticleSetarticleSet =new ArticleSet();

? ? // 對新建的倉庫進行初始化

? ? public void initial () {

Article xiaomi11 =new Article();

? ? ? ? xiaomi11.setArticle("小米11", 50, 2999,1);

? ? ? ? Article xiaomi11Pro =new Article();

? ? ? ? xiaomi11Pro.setArticle("小米11專業(yè)版",30, 3999, 2);

? ? ? ? Article xiaomiULtra =new Article();

? ? ? ? xiaomiULtra.setArticle("小米增強版",66,499,3);

? ? ? ? //把商品放到倉庫中

? ? ? ? articleSet.articles[0] = xiaomi11;

? ? ? ? articleSet.articles[1] = xiaomi11Pro;

? ? ? ? articleSet.articles[2] = xiaomiULtra;

? ? }

//起始菜單

? ? public void startMenu(){

boolean flag =true;

? ? ? ? do {

System.out.println("**********************");

? ? ? ? ? ? System.out.println("1 查看商品信息");

? ? ? ? ? ? System.out.println("2 新增商品信息");

? ? ? ? ? ? System.out.println("3 刪除商品信息");

? ? ? ? ? ? System.out.println("4 賣出商品");

? ? ? ? ? ? System.out.println("5 商品銷售排行榜");

? ? ? ? ? ? System.out.println("6 退出系統(tǒng)");

? ? ? ? ? ? System.out.println("***************************");

? ? ? ? ? ? System.out.println("請輸入你要執(zhí)行的操作");

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

? ? ? ? ? ? int gongnenBianhao = scanner.nextInt();

? ? ? ? ? ? switch (gongnenBianhao) {

case 1:

System.out.println("查看商品信息");

? ? ? ? ? ? ? ? ? ? chakan();? //調(diào)用查看商品信息

? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? case 2:

System.out.println("新增商品信息");

? ? ? ? ? ? ? ? ? ? add();? ? ? //新增商品

? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? case 3:

System.out.println("刪除商品信息");

break;

? ? ? ? ? ? ? ? case 4:

System.out.println("賣出商品");

break;

? ? ? ? ? ? ? ? case 5:

System.out.println("商品銷售排行榜");

break;

? ? ? ? ? ? ? ? case 6:

System.out.println("退出系統(tǒng)");

? ? ? ? ? ? ? ? ? ? flag =false;

break;

? ? ? ? ? ? ? ? default:

System.out.println("請輸入你的功能編號");

break;

? ? ? ? ? ? }

}while (flag);

? ? }

// 查看商品信息

? ? public void chakan(){

System.out.println("編號:\t 名稱 \t 價格 \t 庫存 \t 售出數(shù)量");

? ? ? ? for (int i =0 ; i

if (articleSet.articles[i] !=null ) {

articleSet.articles[i].price(i);

? ? ? ? ? ? }

}

}

//添加商品

? ? public void add() {

System.out.println("請輸入商品名稱");

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

? ? ? ? String name = scanner.next();

? ? ? ? System.out.println("請輸入商品價格");

? ? }

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容