商店管理系统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(){

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 cn.job01;

import java.util.Scanner;

public class Lx07 {

public static void choice() {

System.out.println("登陆菜单 ");

System.out.println("1登陆系统");

System.out.println("2退出");

}

static void choice1() {

System.out.println("购物管理系统客户信息");

System.out.println("1显示所有客户信息");

System.out.println("2添加客户信息");

System.out.println("3修改客户信息");

System.out.println("4查询客户信息");

}

static void choice2() {

System.out.println("购物管理系统真情回馈");

System.out.println("1幸运大放送");

System.out.println("2幸运抽奖");

System.out.println("3生日问候");

}

public static void main(String[] args) {

choice();

Scanner input = new Scanner(System.in);

System.out.println("请输入1or2");

int num = input.nextInt();

switch (num) {

case 1:

System.out.println("主菜单");

System.out.println("1客户信息管理");

System.out.println("2购物结算");

System.out.println("3真情回馈");

System.out.println("4注销");

break;

}

System.out.println("选择输入数字");

int num1 = input.nextInt();

switch (num1) {

case 1:

choice1();

break;

case 2:

System.out.println("购物结算");

break;

case 3:

choice2();

break;

case 4:

choice();

break;

}

}

}

用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语言写的超市管理系统课程设计和源代码吗,能给我吗

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 {

contentPane = (JPanel) this.getContentPane();

jLabel1.setFont(new java.awt.Font("SansSerif", 0, 25));

jLabel1.setForeground(Color.red);

jLabel1.setText("超市管理系统");

contentPane.setLayout(xYLayout1);

this.setSize(new Dimension(500,400));

this.setTitle("超市管理系统");

jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30));

jLabel2.setText("业务单位信息");

jLabel3.setFont(new java.awt.Font("SansSerif", 0, 25));

jLabel3.setText("产品编号");

jTextField1.setText("");

jLabel4.setFont(new java.awt.Font("SansSerif", 0, 25));

jLabel4.setText("公司名称");

jTextField2.setText("");

jLabel5.setFont(new java.awt.Font("SansSerif", 0, 25));

jLabel5.setText("订单号码");

jTextField3.setText("");

jLabel6.setFont(new java.awt.Font("SansSerif", 0, 25));

jLabel6.setText("电 话");

jTextField4.setText("");

jButton1.setFont(new java.awt.Font("SansSerif", 0, 25));

jButton1.setText("提交");

jButton1.addActionListener(new delbook_jButton1_actionAdapter(this));

contentPane.add(jLabel1, new XYConstraints(179, 1, 153, 32));

contentPane.add(jLabel2, new XYConstraints(162, 33, -1, -1));

contentPane.add(jLabel3, new XYConstraints(83, 89, -1, -1));

contentPane.add(jTextField1, new XYConstraints(189, 88, 141, 36));

contentPane.add(jTextField2, new XYConstraints(189, 149, 142, 36));

contentPane.add(jLabel4, new XYConstraints(84, 148, -1, -1));

contentPane.add(jTextField3, new XYConstraints(188, 206, 143, 33));

contentPane.add(jLabel5, new XYConstraints(84, 204, -1, -1));

contentPane.add(jLabel6, new XYConstraints(84, 253, -1, -1));

contentPane.add(jTextField4, new XYConstraints(189, 260, 143, 36));

contentPane.add(jButton1, new XYConstraints(197, 318, -1, -1));

}

//Overridden so we can exit when window is closed

protected void processWindowEvent(WindowEvent e) {

super.processWindowEvent(e);

if (e.getID() == WindowEvent.WINDOW_CLOSING) {

System.exit(0);

}

}

void update() {

try {

//定义显示的字符串

String str1;

String str2;

String str3;

String str4;

str1 = jTextField1.getText();

str2 = jTextField2.getText();

str3 = jTextField3.getText();

str4 = jTextField4.getText();

//装载jdbc驱动程序

String driverName = "oracle.jdbc.OracleDriver";

Driver driver = (Driver) Class.forName(driverName).newInstance();

//连接数据库

Connection con = DriverManager.getConnection(

"jdbc:oracle:thin:@thsspc0791:1521:liuyong", "hr", "tongfang");

PreparedStatement pstmt = con.prepareStatement(

" insert Customer1('goodID','Name','PID','tel')values(?,?,?,?)");

pstmt.setString(1, str1);

pstmt.setString(2, str2);

pstmt.setString(1, str3);

pstmt.setString(4, str4);

ResultSet res = pstmt.executeQuery();

pstmt.close();

con.close();

}catch (InstantiationException e) {

System.out.println(e.getMessage());

}catch (IllegalAccessException e) {

System.out.println(e.getMessage());

}catch (ClassNotFoundException e) {

System.out.println(e.getMessage());

}catch (SQLException edd) {

edd.printStackTrace() ;

System.out.println(edd.getMessage());

}

}

void jButton1_actionPerformed(ActionEvent e) {

update();

}

}

class delbook_jButton1_actionAdapter implements java.awt.event.ActionListener {

delbook adaptee;

delbook_jButton1_actionAdapter(delbook adaptee) {

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent e) {

adaptee.jButton1_actionPerformed(e);

}

}

package untitled5;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import com.borland.jbcl.layout.*;

/**

* pTitle: /p

* pDescription: /p

* pCopyright: Copyright © 2003/p

* pCompany: /p

* @author not attributable

* @version 1.0

*/

public class retur extends JFrame {

JPanel contentPane;

XYLayout xYLayout1 = new XYLayout();

JLabel jLabel1 = new JLabel();

//Construct the frame

public retur() {

enableEvents(AWTEvent.WINDOW_EVENT_MASK);

try {

jbInit();

}

catch(Exception e) {

e.printStackTrace();

}

}

//Component initialization

private void jbInit() throws Exception {

contentPane = (JPanel) this.getContentPane();

jLabel1.setFont(new java.awt.Font("SansSerif", 0, 20));

jLabel1.setForeground(Color.red);

jLabel1.setText("超市管理系统");

contentPane.setLayout(xYLayout1);

this.setSize(new Dimension(400, 300));

this.setTitle("超市管理系统");

contentPane.add(jLabel1, new XYConstraints(139, 1, 126, 33));

}

//Overridden so we can exit when window is closed

protected void processWindowEvent(WindowEvent e) {

super.processWindowEvent(e);

if (e.getID() == WindowEvent.WINDOW_CLOSING) {

System.exit(0);

}

}

}

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.*;

import com.borland.dbswing.*;

//货品信息登记

public class Frame2 extends JFrame {

JPanel contentPane;

JLabel jLabel1 = new JLabel();

XYLayout xYLayout1 = new XYLayout();

JLabel jLabel2 = new JLabel();

JLabel jLabel3 = new JLabel();

JTextField jTextField1 = new JTextField();

JLabel jLabel4 = new JLabel();

JTextField jTextField2 = new JTextField();

JPanel jPanel1 = new JPanel();

XYLayout xYLayout2 = new XYLayout();

JScrollPane jScrollPane1 = new JScrollPane();

JLabel jLabel5 = new JLabel();

JTextField jTextField3 = new JTextField();

//Construct the frame

public Frame2() {

enableEvents(AWTEvent.WINDOW_EVENT_MASK);

try {

jbInit();

}

catch(Exception e) {

e.printStackTrace();

}

}

//Component initialization

private void jbInit() throws Exception {

contentPane = (JPanel) this.getContentPane();

contentPane.setLayout(xYLayout1);

this.setSize(new Dimension(600, 500));

this.setTitle("超市管理系统");

this.addHierarchyBoundsListener(new Frame2_this_hierarchyBoundsAdapter(this));

jLabel1.setFont(new java.awt.Font("SansSerif", 0, 25));

jLabel1.setForeground(Color.red);

jLabel1.setText("超市管理系统");

contentPane.setForeground(Color.black);

jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30));

jLabel2.setText("产 品 信 息 展 示");

// statusBar.setFont(new java.awt.Font("SansSerif", 0, 20));

jLabel3.setFont(new java.awt.Font("SansSerif", 0, 20));

jLabel3.setText("产品名称");

jTextField1.setText("");

jLabel4.setEnabled(true);

jLabel4.setFont(new java.awt.Font("SansSerif", 0, 20));

jLabel4.setText("产品ID号");

jTextField2.setText("");

jTextField2.addActionListener(new Frame2_jTextField2_actionAdapter(this));

jPanel1.setLayout(xYLayout2);

jLabel5.setFont(new java.awt.Font("SansSerif", 0, 25));

jLabel5.setForeground(Color.red);

jLabel5.setText("该产品详细信息");

jTextField3.setText("");

contentPane.add(jLabel1, new XYConstraints(237, 0, 153, 40));

contentPane.add(jLabel2, new XYConstraints(200, 47, 231, 58));

contentPane.add(jLabel3, new XYConstraints(47, 102, 101, 42));

contentPane.add(jTextField1, new XYConstraints(128, 108, 112, 34));

contentPane.add(jTextField2, new XYConstraints(361, 107, 109, 36));

contentPane.add(jPanel1, new XYConstraints(75, 166, 453, 277));

jPanel1.add(jScrollPane1, new XYConstraints(14, 8, 433, 221));

jScrollPane1.getViewport().add(jTextField3, null);

jPanel1.add(jLabel5, new XYConstraints(112, 240, -1, -1));

contentPane.add(jLabel4, new XYConstraints(278, 111, -1, -1));

}

//Overridden so we can exit when window is closed

protected void processWindowEvent(WindowEvent e) {

super.processWindowEvent(e);

if (e.getID() == WindowEvent.WINDOW_CLOSING) {

System.exit(0);

}

}

void Select() {

try {

String str1, str2;

str1 = jTextField1.getText();

str2 = jTextField2.getText();


本文标题:商店管理系统java代码 java商城代码
网站路径:http://cdiso.cn/article/doseede.html

其他资讯