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

跪求一個小型超市管理系統(tǒng),用java編寫的,急~ 只要源代碼。。可以發(fā)我郵箱

import java.sql.Connection;

創(chuàng)新互聯(lián)建站是一家集網(wǎng)站建設(shè),蔚縣企業(yè)網(wǎng)站建設(shè),蔚縣品牌網(wǎng)站建設(shè),網(wǎng)站定制,蔚縣網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,蔚縣網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

public class Conn {

private static final String driver="com.mysql.jdbc.Driver";

private static final String url="jdbc:mysql://localhost:3306/blog?user=rootpassword=root";

//獲得數(shù)據(jù)庫連接

public static Connection getConnection(){

Connection conn = null;

try {

Class.forName(driver);

conn = DriverManager.getConnection(url);

if(conn != null){

System.out.print("成功");

}

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

return conn;

}

//關(guān)閉Resultset

public static void closeResultSet(ResultSet rs)

{

try

{

if(rs != null)

{

rs.close();

}

}catch (SQLException ex)

{

ex.printStackTrace();

}

}

//關(guān)閉Statement

public static void closeStatement(Statement st)

{

try

{

if(st != null)

{

st.close();

}

}catch (SQLException ex)

{

ex.printStackTrace();

}

}

//關(guān)閉Connection

public static void closeConnection(Connection conn)

{

try

{

if(conn != null)

{

conn.close();

}

}catch (SQLException ex)

{

ex.printStackTrace();

}

}

//測試數(shù)據(jù)庫連接是否成功

public static void main(String[] args) {

Conn.getConnection();

}

}

java超市管理系統(tǒng)源代碼

只寫個demo級的例程很好寫,但用到生產(chǎn)環(huán)境中還得具體分析設(shè)計再編碼。這種代碼網(wǎng)上太多了內(nèi),你隨便搜下就有了。

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

}

}

}

java超市計價系統(tǒng)代碼

package?entity;

public?class?Market?{

private?int?id;//id

private?int?num;//數(shù)量

private?String?goods;//商品

private?double?price;//價格

public?Market(int?id,?int?num,?String?goods,?double?price)?{

super();

this.id?=?id;

this.num?=?num;

this.goods?=?goods;

this.price?=?price;

}

public?int?getId()?{

return?id;

}

public?void?setId(int?id)?{

this.id?=?id;

}

public?int?getNum()?{

return?num;

}

public?void?setNum(int?num)?{

this.num?=?num;

}

public?String?getGoods()?{

return?goods;

}

public?void?setGoods(String?goods)?{

this.goods?=?goods;

}

public?double?getPrice()?{

return?price;

}

public?void?setPrice(double?price)?{

this.price?=?price;

}

public?double?calc(?){

double?sum=price*num;

System.out.println("您消費共計:"+sum+"¥");

return?sum;

}

}

package?test;

import?java.util.HashMap;

import?java.util.Map;

import?java.util.Scanner;

import?entity.Market;

public?class?Test?{

private?static?MapInteger,Market?goods=new?HashMapInteger,?Market();

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

System.out.println("-------超市計價系統(tǒng)-------");

String?goods1="可口可樂";

String?goods2="爆米花";

String?goods3="益達";

printTable("編號","商品","價格");

printTable("1",goods1,"3.0¥");

printTable("2",goods2,"5.0¥");

printTable("3",goods3,"10.0¥");

goods.put(1,?new?Market(1,?1,?goods1,?3.0));

goods.put(2,?new?Market(2,?1,??goods2,?5.0));

goods.put(3,?new?Market(3,?1,?goods3,?10.0));

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

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

int?num?=?input.nextInt();

System.out.println("請輸入商品的數(shù)量");

int?amount?=?input.nextInt();

Market?market?=?goods.get(num);

market.setNum(amount);

market.calc();

}

private?static?void?printTable(String?row1,String?row2,String?row3?)?{

System.out.print(row1);

int?times=12;

if?(row2!="商品")?{

times=5;

}

for?(int?i?=?0;?i??times;?i++)?{

System.out.print("?");

}

System.out.print(row2);

for?(int?i?=?0;?i??10;?i++)?{

System.out.print("?");

}

System.out.print(row3);

System.out.println("\n");

}

}

//測試結(jié)果:

-------超市計價系統(tǒng)-------

編號????????????商品??????????價格

1?????可口可樂??????????3.0¥

2?????爆米花??????????5.0¥

3?????益達??????????10.0¥

請輸入商品的編號:

3

請輸入商品的數(shù)量

5

您消費共計:50.0¥

親有java語言寫的超市管理系統(tǒng)課程設(shè)計和源代碼嗎,能給我嗎

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("超市管理系統(tǒng)");

contentPane.setLayout(xYLayout1);

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

this.setTitle("超市管理系統(tǒng)");

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

jLabel2.setText("業(yè)務(wù)單位信息");

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

jLabel3.setText("產(chǎn)品編號");

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驅(qū)動程序

String driverName = "oracle.jdbc.OracleDriver";

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

//連接數(shù)據(jù)庫

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("超市管理系統(tǒng)");

contentPane.setLayout(xYLayout1);

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

this.setTitle("超市管理系統(tǒng)");

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("超市管理系統(tǒng)");

this.addHierarchyBoundsListener(new Frame2_this_hierarchyBoundsAdapter(this));

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

jLabel1.setForeground(Color.red);

jLabel1.setText("超市管理系統(tǒng)");

contentPane.setForeground(Color.black);

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

jLabel2.setText("產(chǎn) 品 信 息 展 示");

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

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

jLabel3.setText("產(chǎn)品名稱");

jTextField1.setText("");

jLabel4.setEnabled(true);

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

jLabel4.setText("產(chǎn)品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("該產(chǎn)品詳細信息");

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編寫購物系統(tǒng)的代碼是什么?(急)

算是最簡單的吧

package cn.job01;

import java.util.Scanner;

public class Lx07 {

public static void choice() {

System.out.println("登陸菜單 ");

System.out.println("1登陸系統(tǒng)");

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

}

static void choice1() {

System.out.println("購物管理系統(tǒng)客戶信息");

System.out.println("1顯示所有客戶信息");

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

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

System.out.println("4查詢客戶信息");

}

static void choice2() {

System.out.println("購物管理系統(tǒng)真情回饋");

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購物結(jié)算");

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

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

break;

}

System.out.println("選擇輸入數(shù)字");

int num1 = input.nextInt();

switch (num1) {

case 1:

choice1();

break;

case 2:

System.out.println("購物結(jié)算");

break;

case 3:

choice2();

break;

case 4:

choice();

break;

}

}

}

網(wǎng)站標(biāo)題:java超市系統(tǒng)源代碼的簡單介紹
URL地址:http://muchs.cn/article26/hheijg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、ChatGPT網(wǎng)站設(shè)計公司、網(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)

成都app開發(fā)公司