网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

java购物系统代码文库 java购物程序

用JAVA编写购物系统的代码是什么?(急)

算是最简单的吧

创新互联专注于企业网络营销推广、网站重做改版、榆次网站定制设计、自适应品牌网站建设、H5网站设计成都做商城网站、集团公司官网建设、成都外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为榆次等各大城市提供网站开发制作服务。

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 的电商系统的完整源码+文档

public void main(String [] arg){

system.out.print("哈哈哈");

system.out.print("就不告诉你");

}

购物车的Java代码

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Iterator;public class ShoppingCartManager {

HashMapString, String hm=new HashMapString, String();

float totlePrice=0;

//添加book到购物车

public void addBook(String bookId,String bookQuantity){

if(hm.containsKey(bookId)){

int value=Integer.parseInt(hm.get(bookId));

value+=Integer.parseInt(bookQuantity);

hm.put(bookId, value+"");

}else{

hm.put(bookId, bookQuantity);

}

}

//修改数量

public void updateQuantity(String bookId,String bookQuantity){

hm.put(bookId, bookQuantity);

}

//获取购物车的所有信息 并计算总价

public ArrayListBookBean getShoppingCart(){

ArrayListBookBean al=new ArrayListBookBean();

IteratorString i=hm.keySet().iterator();

String ids="";

BookTableManager btm=new BookTableManager();

while(i.hasNext()){

ids=ids+","+i.next();

}

al= btm.selectByBookIds(ids);

totlePrice=0; //清空总价,防止无限累计

for(int j=0;jal.size();j++){

BookBean bb=al.get(j);

totlePrice+=bb.getPrice()*Integer.parseInt(getQuantityById(bb.getBookId()+""));

}

return al;

}

//获取总价

public float getTotlePrice(){

return totlePrice;

}

//根据ID获取数量

public String getQuantityById(String id){

String quantity=hm.get(id);

return quantity;

}

//清空购物车

public void clear(){

hm.clear();

}

//删除购物车中的一本书

public void deleteById(String id){

hm.remove(id);

}

}

JAVA 购物车示例代码

import java.awt.*;

import java.awt.event.*;

class ShopFrame extends Frame implements ActionListener

{ Label label1,label2,label3,label4;

Button button1,button2,button3,button4,button5;

TextArea text;

Panel panel1,panel2;

static float sum=0.0f;

ShopFrame(String s)

{ super(s);

setLayout(new BorderLayout());

label1=new Label("面纸:3元",Label.LEFT);

label2=new Label("钢笔:5元",Label.LEFT);

label3=new Label("书:10元",Label.LEFT);

label4=new Label("袜子:8元",Label.LEFT);

button1=new Button("加入购物车");

button2=new Button("加入购物车");

button3=new Button("加入购物车");

button4=new Button("加入购物车");

button5=new Button("查看购物车");

text=new TextArea("商品有:"+"\n",5,10);

text.setEditable(false);

addWindowListener(new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{ System.exit(0);

}

}

);

button1.addActionListener(this);

button2.addActionListener(this);

button3.addActionListener(this);

button4.addActionListener(this);

button5.addActionListener(this);

panel1=new Panel();

panel2=new Panel();

panel1.add(label1);

panel1.add(button1);

panel1.add(label2);

panel1.add(button2);

panel1.add(label3);

panel1.add(button3);

panel1.add(label4);

panel1.add(button4);

panel2.setLayout(new BorderLayout());

panel2.add(button5,BorderLayout.NORTH);

panel2.add(text,BorderLayout.SOUTH);

this.add(panel1,BorderLayout.CENTER);

this.add(panel2,BorderLayout.SOUTH);

setBounds(100,100,350,250);

setVisible(true);

validate();

}

public void actionPerformed(ActionEvent e)

{ if(e.getSource()==button1)

{ text.append("一个面纸、");

sum=sum+3;

}

else if(e.getSource()==button2)

{ text.append("一只钢笔、");

sum=sum+5;

}

else if(e.getSource()==button3)

{ text.append("一本书、");

sum=sum+10;

}

else if(e.getSource()==button4)

{ text.append("一双袜子、");

sum=sum+8;

}

else if(e.getSource()==button5)

{

text.append("\n"+"总价为:"+"\n"+sum);

}

}

}

public class Shopping {

public static void main(String[] args) {

new ShopFrame("购物车");

}

}

我没用Swing可能显示不出来你的效果。不满意得话我在给你编一个。


新闻名称:java购物系统代码文库 java购物程序
网站URL:http://bjjierui.cn/article/doghded.html

其他资讯