java超市登錄系統(tǒng)代碼的簡單介紹

Java編程,簡單超市系統(tǒng)?。」蚯蟀?/h2>

import java.util.Vector; class Supermarket{ Vector market = null; Supermarket(){ market = new Vector(); } public void append(Goods g){ market.addElement(g); } public void delete(Goods g){ market.removeElement(g); } public void query(Goods g){ for(int i = 0;imarket.size();i++){ if((market.elementAt(i)).equals(g) == true){ g.showMe(); } } } } class Goods{ private String name; private double price; private int num; public Goods(String name,double price,int num){ this.name=name; this.price = price; this.num = num; } public void sale(double buyprice){ if(num==0){ System.out.println("購買商品已售空"); return; } if(buypricethis.price){ System.out.println("余額不足"); }else{ num--; } } public void add(int quantity){ num+=quantity; } public void showMe(){ System.out.println("商品名稱:"+this.name+" 商品價格:"+this.price+"$ "+"商品個數(shù):"+this.num); } } //很多地方給的不是很詳細,只能這么憑理解寫,測試main方法自己寫。

我們提供的服務(wù)有:成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、鐵嶺ssl等。為近1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的鐵嶺網(wǎng)站制作公司

需要一JAVA寫成的超市管理系統(tǒng)!主要就是超市貨品的添加,查詢功能等!

/**

*?超市管理系統(tǒng)

*?@author?Administrator

*

*/

public?class?ChaoShiSystemManager?{

public?static?void?main(String[]?args)?{

new?HuoWuDomImpl().start();

}

}

class?HuoWu{

public?String?bianhao;?//商品編號

public?String?name;?//商品名稱

public?double?jiage;?//商品價格

}

class?HuoWuDomImpl{

private?static?java.util.ArrayListHuoWu?list?=?new?java.util.ArrayListHuoWu();

public?void?start(){

?int?num?=?0;

System.out.println("--歡迎登錄超市管理系統(tǒng)--");

System.out.println("1、添加商品");

System.out.println("2、查詢商品");

java.util.Scanner?sc?=?new?java.util.Scanner(System.in);

System.out.println("請輸入模塊名稱:");

try?{

num?=?sc.nextInt();

if(num?==?1){

setHuoWu();

new?HuoWuDomImpl().start();

}else?if(num?==?2){

getSeleteHuoWu();

new?HuoWuDomImpl().start();

}else{

throw?new?RuntimeException("提示:抱歉,模塊正在開發(fā)中");

}

}?catch?(Exception?e)?{

e.printStackTrace();

throw?new?RuntimeException("提示:對不起,您的輸入有誤!");

}finally{

sc.close();

}

}

public?void?setHuoWu(){

HuoWu?hw?=?new?HuoWu();

java.util.Scanner?sc?=?new?java.util.Scanner(System.in);

System.out.println("請輸入商品編號:");

hw.bianhao?=?sc.next();

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

hw.name?=?sc.next();

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

try?{

hw.jiage?=?sc.nextDouble();

}?catch?(Exception?e)?{

throw?new?RuntimeException("提示:商品價格輸入錯誤!");

}finally{

sc.close();

}

list.add(hw);

System.out.println("提示:恭喜,添加成功!");

}

public?void?getSeleteHuoWu(){

java.util.Scanner?sc?=?new?java.util.Scanner(System.in);

System.out.println("請輸入商品編號...");

String?bianhao?=?sc.next();

java.util.Iterator?it?=?list.iterator();

while(it.hasNext()){

if(bianhao.equals(((HuoWu)it.next()).bianhao)){

System.out.println("商品編號:"?+?((HuoWu)it.next()).bianhao);

System.out.println("商品名稱:"?+?((HuoWu)it.next()).name);

System.out.println("商品價格:"?+?((HuoWu)it.next()).jiage);

}

}

}

}

PS:程序可能還有點問題,自己調(diào)試一下吧。改天有空我再來更新。

用java語言寫個超市管理系統(tǒng)的程序

package?c;

import?java.util.Scanner;

public?class?SuperMarket?{

static?Scanner?scan?=?new?Scanner(System.in);

public?static?String?str;

public?static?void?main(String[]?args)?{

showMsg();

while?(scan.hasNext())?{

switch?(scan.nextInt())?{

case?1:

commodityManage();

break;

case?2:

customerManage();

break;

case?3:

orderManage();

break;

case?4:

exitSystem();

break;

default:

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

break;

}

}

scan.close();

}

/**

?*?顯示信息

?*/

public?static?void?showMsg()?{

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

System.out.println("\t超??市??庫??存??管??理??系??統(tǒng)\t");

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

System.out.println("1、商品管理");

System.out.println("2、客戶管理");

System.out.println("3、訂單管理");

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

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

System.out.println("請輸入您的選擇(1-4):");

}

/**

?*?選項?1、商品管理

?*/

public?static?void?commodityManage()?{

str?=?"商品管理";

showWelcom(str);

System.out.println("以上為商品管理的信息!\n是否繼續(xù)?(按1繼續(xù)/其他結(jié)束):");

exitOrShow(1);

}

/**

?*?選項?2、客戶管理

?*/

public?static?void?customerManage()?{

str?=?"客戶管理";

System.out.println("以上為客戶管理的信息!\n是否繼續(xù)?(按2繼續(xù)/其他結(jié)束):");

exitOrShow(2);

}

/**

?*?選項?3、訂單管理

?*/

public?static?void?orderManage()?{

str?=?"訂單管理";

System.out.println("以上為訂單管理的信息!\n是否繼續(xù)?(按3繼續(xù)/其他結(jié)束):");

exitOrShow(3);

}

/**

?*?選項?4、退出系統(tǒng)

?*/

public?static?void?exitSystem()?{

System.exit(0);

}

public?static?void?showWelcom(String?str)?{

System.out.println("歡迎進入"+?str?+"模塊");

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

}

public?static?void?exitOrShow(int?nextInt)?{

if?(scan.nextInt()?!=?nextInt)?{

exitSystem();

}?else?{

showMsg();

}

}

}

網(wǎng)頁標題:java超市登錄系統(tǒng)代碼的簡單介紹
文章來源:http://www.muchs.cn/article0/ddceoio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、、建站公司、電子商務(wù)、營銷型網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站