网站建设资讯

NEWS

网站建设资讯

java超市登录系统代码的简单介绍

Java编程,简单超市系统!!跪求啊

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+"$ "+"商品个数:"+this.num); } } //很多地方给的不是很详细,只能这么凭理解写,测试main方法自己写。

我们提供的服务有:成都网站建设、成都网站设计、微信公众号开发、网站优化、网站认证、铁岭ssl等。为近1000家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的铁岭网站制作公司

需要一JAVA写成的超市管理系统!主要就是超市货品的添加,查询功能等!

/**

* 超市管理系统

* @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("--欢迎登录超市管理系统--");

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("提示:抱歉,模块正在开发中");

}

} 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:程序可能还有点问题,自己调试一下吧。改天有空我再来更新。

用java语言写个超市管理系统的程序

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");

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

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

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

System.out.println("3、订单管理");

System.out.println("4、退出系统");

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

System.out.println("请输入您的选择(1-4):");

}

/**

 * 选项 1、商品管理

 */

public static void commodityManage() {

str = "商品管理";

showWelcom(str);

System.out.println("以上为商品管理的信息!\n是否继续?(按1继续/其他结束):");

exitOrShow(1);

}

/**

 * 选项 2、客户管理

 */

public static void customerManage() {

str = "客户管理";

System.out.println("以上为客户管理的信息!\n是否继续?(按2继续/其他结束):");

exitOrShow(2);

}

/**

 * 选项 3、订单管理

 */

public static void orderManage() {

str = "订单管理";

System.out.println("以上为订单管理的信息!\n是否继续?(按3继续/其他结束):");

exitOrShow(3);

}

/**

 * 选项 4、退出系统

 */

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();

}

}

}


网页标题:java超市登录系统代码的简单介绍
网站网址:http://cdweb.net/article/ddceoio.html