java代码超市 java超市购物代码

需要一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(){
【java代码超市 java超市购物代码】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 untitled5;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.lang.*;
import javax.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class delbook extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel4 = new JLabel();
JTextField jTextField2 = new JTextField();
JLabel jLabel5 = new JLabel();
JTextField jTextField3 = new JTextField();
JLabel jLabel6 = new JLabel();
JTextField jTextField4 = new JTextField();
JButton jButton1 = new JButton();
//Construct the frame
public delbook() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {

推荐阅读