成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

java小超市項目的代碼 超市購物小程序java

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

/**

成都創(chuàng)新互聯(lián)公司公司2013年成立,先為當陽等服務(wù)建站,當陽等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為當陽企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

*?超市管理系統(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?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¥

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

import java.sql.Connection;

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小超市項目的代碼 超市購物小程序java
瀏覽路徑:http://jinyejixie.com/article42/dophohc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計公司、自適應(yīng)網(wǎng)站、企業(yè)建站網(wǎng)站策劃、網(wǎng)站收錄、小程序開發(fā)

廣告

聲明:本網(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)站建設(shè)網(wǎng)站維護公司
焉耆| 客服| 浦江县| 同仁县| 东港市| 长垣县| 西宁市| 武安市| 大厂| 澄江县| 渝北区| 富顺县| 洛宁县| 黄浦区| 静海县| 嘉鱼县| 永清县| 镇巴县| 郓城县| 丹寨县| 苏尼特右旗| 元朗区| 商水县| 嘉黎县| 屏东县| 高清| 化隆| 古交市| 峨山| 永和县| 沙湾县| 吐鲁番市| 泰州市| 高淳县| 呼伦贝尔市| 郎溪县| 大安市| 黄骅市| 定边县| 岳阳市| 文安县|