「java购物系统」java在线购物系统

博主:adminadmin 2022-12-05 01:30:08 56

今天给各位分享java购物系统的知识,其中也会对java在线购物系统进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

用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项目实训模拟网上超市购物结算功能

使用结构体+数组,就可以 了

~

~

~

~

~~~~~~~~~~~~~~~~~~~~~~~~~

java web网上商城购物系统 他们背后添加商品或修改商品信息是怎样做的呢

这需要做后台服务系统,购物系统许多都是分前台和后台的,,前台基本上是做显示物品信息,用户提交订单等,,后台做物品信息的增删改查,前台页面的显示属性等等,,,我就是做的网上购书系统,,为毕业设计,,嘻嘻:-D

JAVA语言编写的网上订餐系统购物车功能如何实现?

用Vector 或者是HashMap去装

下面有部分代码你去看吧

package com.aptech.restrant.DAO;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Set;

import java.sql.Connection;

import com.aptech.restrant.bean.CartItemBean;

import com.aptech.restrant.bean.FoodBean;

public class CartModel {

private Connection conn;

public CartModel(Connection conn) {

this.conn=conn;

}

/**

* 得到订餐列表

* @return

*/

public List changeToList(Map carts) {

// 将Set中元素转换成数组,以便使用循环进行遍历

Object[] foodItems = carts.keySet().toArray();

// 定义double变量total,用于存放购物车内餐品总价格

double total = 0;

List list = new ArrayList();

// 循环遍历购物车内餐品,并显示各个餐品的餐品名称,价格,数量

for (int i = 0; i  foodItems.length; i++) {

// 从Map对象cart中取出第i个餐品,放入cartItem中

CartItemBean cartItem = (CartItemBean) carts

.get((String) foodItems[i]);

// 从cartItem中取出FoodBean对象

FoodBean food1 = cartItem.getFoodBean();

// 定义int类型变量quantity,用于表示购物车中单个餐品的数量

int quantity = cartItem.getQuantity();

// 定义double变量price,表示餐品单价

double price = food1.getFoodPrice();

// 定义double变量,subtotal表示单个餐品总价

double subtotal = quantity * price;

// // 计算购物车内餐品总价格

total += subtotal;

cartItem.setSubtotal(subtotal);

cartItem.setTotal(total);

list.add(cartItem);

}

return list;

}

/**

* 增加订餐

*/

public Map add(Map cart, String foodID) {

// 购物车为空

if (cart == null) {

cart = new HashMap();

}

FoodModel fd = new FoodModel(conn);

FoodBean food = fd.findFoodById(foodID);

// 判断购物车是否放东西(第一次点餐)

if (cart.isEmpty()) {

CartItemBean cartBean = new CartItemBean(food, 1);

cart.put(foodID, cartBean);

} else {

// 判断当前菜是否在购物车中,false表示当前菜没有被点过。。

boolean flag = false;

// 得到键的集合

Set set = cart.keySet();

// 遍历集合

Object[] obj = set.toArray();

for (int i = 0; i  obj.length; i++) {

Object object = obj[i];

// 如果购物车已经存在当前菜,数量+1

if (object.equals(foodID)) {

int quantity = ((CartItemBean) cart.get(object))

.getQuantity();

quantity += 1;

System.out.println(quantity);

((CartItemBean) cart.get(object)).setQuantity(quantity);

flag = true;

break;

}

}

if (flag == false) {

// 把当前菜放到购物车里面

CartItemBean cartBean = new CartItemBean(food, 1);

cart.put(foodID, cartBean);

}

}

return cart;

}

/**

* 取消订餐

*/

public Map remove(Map cart, String foodID) {

cart.remove(foodID);

return cart;

}

/**

* 更新购物车信息

* @param cart

* @param foodID

* @return

*/

public MapString, CartItemBean update(Map cart, String foodID,

boolean isAddorRemove) {

Map map;

if (isAddorRemove) {

map = add(cart, foodID);

} else {

map = remove(cart, foodID);

}

return map;

}

}

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 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购物系统和java在线购物系统的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-12-05,除非注明,否则均为首码项目网原创文章,转载请注明出处。