一个简易的网上书店吧
package com.coding.study12;import java.util.Scanner;public class Demo01 {public static void main(String[] args) {while (true) {Scanner scanner = new Scanner(System.in);System.out.println("----欢迎使用在线购书平台----");System.out.println("首次登录请按" + "#" + "注册");String account = scanner.nextLine();if (account.equals("#")) {System.out.println("请输入注册用户属性boss/customer:");String type = scanner.nextLine();if (type.equals("boss")) {System.out.println("请输入新的账号:");String account1 = scanner.nextLine();System.out.println("请输入新的密码:");String passwd1 = scanner.nextLine();System.out.println("请输入姓名:");String name1 = scanner.nextLine();Operation.regist(account1, passwd1, name1, type);} else if (type.equals("customer")) {System.out.println("请输入新的账号:");String account2 = scanner.nextLine();System.out.println("请输入新的密码:");String passwd2 = scanner.nextLine();System.out.println("请输入姓名:");String name2 = scanner.nextLine();Operation.regist(account2, passwd2, name2, type);}} else {System.out.println("请输入账户密码:");String passwd = scanner.nextLine();System.out.println("请输入用户类型boss/customer:");String type = scanner.nextLine();Operation.logine(account, passwd, type);// Scanner scanner2 = new Scanner(System.in);// Scanner scanner3 = new Scanner(System.in);if (type.equals("boss")) {operateBoss();continue;} else if (type.equals("customer")) {operateCustomer();continue;}}}}public static void operateBoss() {Scanner scanner = new Scanner(System.in);Scanner scanner1 = new Scanner(System.in);Scanner scanner2 = new Scanner(System.in);while (true) {System.out.println("请输入你要执行的操作:");System.out.println("1.添加书籍");System.out.println("2.查看库存");System.out.println("3.退出系统");int n = scanner2.nextInt();switch (n) {case 1:System.out.println("请输入书籍名:");String name = scanner.nextLine();System.out.println("请输入书籍作者:");String author = scanner.nextLine();System.out.println("请输入出版社:");String press = scanner.nextLine();System.out.println("请输入书籍价格:");double price = scanner1.nextDouble();System.out.println("请输入书籍数量:");int amount = scanner2.nextInt();Operation.add(name, author, press, price, amount);break;case 2:Operation.check();break;case 3:return;default:System.out.println("输入错误请重新输入");break;}}}public static void operateCustomer() {Scanner scanner = new Scanner(System.in);Scanner scanner1 = new Scanner(System.in);Scanner scanner2 = new Scanner(System.in);while (true) {System.out.println("请输入你要执行的操作:");System.out.println("1.添加购物车");System.out.println("2.查看店铺书籍");System.out.println("3.查看订单");System.out.println("4.退出");int n = scanner2.nextInt();switch (n) {case 1:System.out.println("请输入要购买的书籍:");String name=scanner.nextLine();Operation.addGoods(name);break;case 2:System.out.println("店铺书籍有:");Operation.check();break;case 3:System.out.println("您的订单详情:");Operation.query();break;case 4:return;default:System.out.println("输入错误请重新输入");break;}}}
}
package com.coding.study12;public class Boss {String account;String passwd;String name;public Boss(String account, String passwd, String name) {super();this.account = account;this.passwd = passwd;this.name = name;}public String getAccount() {return account;}public void setAccount(String account) {this.account = account;}public String getPasswd() {return passwd;}public void setPasswd(String passwd) {this.passwd = passwd;}public String getName() {return name;}public void setName(String name) {this.name = name;}}
package com.coding.study12;public class Customer {String account;String passwd;String name;public Customer(String account, String passwd, String name) {super();this.account = account;this.passwd = passwd;this.name = name;}public String getAccount() {return account;}public void setAccount(String account) {this.account = account;}public String getPasswd() {return passwd;}public void setPasswd(String passwd) {this.passwd = passwd;}public String getName() {return name;}public void setName(String name) {this.name = name;}
}
package com.coding.study12;public class Books {String name;String author;String press;double price;int amount;public Books(String name, String author, String press, double price, int amount) {super();this.name = name;this.author = author;this.press = press;this.price = price;this.amount = amount;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getAuthor() {return author;}public void setAuthor(String author) {this.author = author;}public String getPress() {return press;}public void setPress(String press) {this.press = press;}public double getPrice() {return price;}public void setPrice(double price) {this.price = price;}public int getAmount() {return amount;}public void setAmount(int amount) {this.amount = amount;}}
package com.coding.study12;public class Operation {public static void regist(String account, String passwd, String name, String type) {Boss boss = new Boss(account, passwd, name);Customer customer = new Customer(account, passwd, name);if (type.equals("boss")) {for (int i = 0; i < Tools.bosses.length; i++) {if (Tools.bosses[i] == null) {Tools.bosses[i] = boss;System.out.println("boss注册成功!!!");break;}}} else if (type.equals("customer")) {for (int i = 0; i < Tools.customers.length; i++) {if (Tools.customers[i] == null) {Tools.customers[i] = customer;System.out.println("customer注册成功!!!");break;}}}}public static void logine(String account, String passwd, String type) {if (type.equals("boss")) {for (int i = 0; i < Tools.bosses.length; i++) {if (Tools.bosses[i] != null) {if (account.equals(Tools.bosses[i].getAccount()) && passwd.equals(Tools.bosses[i].getPasswd())) {System.out.println("欢迎boss:" + Tools.bosses[i].getName());// return true;}}}} else if (type.equals("customer")) {for (int i = 0; i < Tools.customers.length; i++) {if (Tools.customers[i] != null) {if (account.equals(Tools.customers[i].getAccount())&& passwd.equals(Tools.customers[i].getPasswd())) {System.out.println("欢迎customer:" + Tools.customers[i].getName() + "光临");// return true;}}}}// return false;}public static void add(String name, String author, String press, double price, int amount) {Books book = new Books(name, author, press, price, amount);for (int i = 0; i < Tools.books.length; i++) {if (Tools.books[i] == null) {Tools.books[i] = book;System.out.println("存储书籍信息成功");break;}}}public static void check() {for (int i = 0; i < Tools.books.length; i++) {if (Tools.books[i] != null) {System.out.println("书籍名:" + Tools.books[i].getName());System.out.println("作者:" + Tools.books[i].getAuthor());System.out.println("出版社:" + Tools.books[i].getPress());System.out.println("价格:" + Tools.books[i].getPrice());System.out.println("库存数:" + Tools.books[i].getAmount());}}}public static void addGoods(String name) {GoodsCar goods = new GoodsCar(name);for (int i = 0; i < Tools.goodsCar.length; i++) {if (Tools.goodsCar[i] == null) {Tools.goodsCar[i] = goods;System.out.println("添加购物车成功!");break;}}}public static void query() {double money = 0;int num = 0;for (int i = 0; i < Tools.goodsCar.length; i++) {if (Tools.goodsCar[i] != null) {System.out.println(Tools.goodsCar[i].getName());for (int j = 0; j < Tools.books.length; j++) {if (Tools.books[j]!=null) {if (Tools.goodsCar[i].getName().equals(Tools.books[j].getName())) {money = money + Tools.books[j].getPrice();num++;Tools.books[j].setAmount(Tools.books[j].getAmount()-1);}}}}}System.out.println("您共买了" + num + "本书,总价为¥:" + money);}
}
package com.coding.study12;public class GoodsCar {String name;String price;public GoodsCar(String name) {super();this.name = name;
// this.price = price;}public String getName() {return name;}public void setName(String name) {this.name = name;}
// public String getPrice() {
// return price;
// }
// public void setPrice(String price) {
// this.price = price;
// }}
package com.coding.study12;public class Tools {public static Books[] books=new Books[100];public static Boss[] bosses=new Boss[100];public static Customer[] customers=new Customer[100];public static GoodsCar[] goodsCar=new GoodsCar[100];
}
一个简易的网上书店吧相关推荐
- java web网上书店_java web简易网上书店项目系列,使用MVC模式(servlet+jstl+dbutils),开篇...
一. 针对很多java web初学者入门困难的问题,笔者利用一个小型web项目,一步一步的展示java web开发方法,每一个章节引入一些java web开发的重点知识,让同学们可以将java web ...
- javaweb课程设计网上书店
网上书店系统是一个基于Internet,采用B2C(Business to Consumers)模式,并根据现有的网上书店系统的现状而设计开发的电子商务平台.本文以JSP为开发技术,实现了一个虚拟的网 ...
- [附源码]java毕业设计网上书店管理系统
项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...
- java网上书店管理系统_基于JAVA的网上书店管理系统的开发.doc
基于JAVA的网上书店管理系统的开发 基于 JAVA 的网上书店系统的设计与开发 摘 要 电子商务是一种在互联网上进行商务活动的形式,近年来随着互联网技术的 发展得以迅速普及.如何利用最新互联网编程技 ...
- 基于jsp的网上书店系统设计与实现
网上书店系统是一个基于Internet,采用B2C(Business to Consumers)模式,并根据现有的网上书店系统的现状而设计开发的电子商务平台. 本文以JSP为开发技术,实现了一个虚拟的 ...
- 使用MVC模式实现一个超简单的网上书店系统
使用MVC模式实现网上书店(大二实验报告) 1.问题描述: 主页面要求实现如下图所示: 登录前,若选择"个人中心",则提示请登录:登录后,页面显示如图所示: 在主页面显示" ...
- 举一个在网上书店系统中的数据库存储过程设计的例子
在网上书店系统中,可以设计一个存储过程来查询当前库存中某一类型的书的数量.这个存储过程的名称可以叫做 "GetBookCountByType",它接受一个参数 "book ...
- javaweb JAVA JSP图书销售系统JSP网上书店商城JSP购物系统JSP网上书店JSP图书在线销售系统JSP图书商城jsp二手图书销售系
JSP图书销售系统JSP网上书店商城JSP购物系统JSP网上书店JSP图书在线销售系统JSP图书商城jsp图书销售系 常见的Javaweb题材有 理财系统,就业管理系统,汽车租赁,简易网盘,疫情数据查 ...
- 网上书店可行性分析报告(原创)
网上书店可行性分析报告 1 引言 1.1 编写目的:本文档将描述对网上书店(电子商务网站)项目的可行性研究. 1.2 项目背景: 本项目作为<软件工程>课程的实习项目提出,希望通过< ...
最新文章
- ajax跨域问题解决方案
- mysql特别点_Mysql 特别注意点!
- linux内网穿透局域网frp(实现有网就能访问你的局域网台式机服务器)
- 怎样将employee 加到Territory里
- c# 窗口句柄问题 。
- 帧同步和状态同步(二)案例分析
- 西电网络攻防大赛--渗透测试第二题
- 【Java基础总结】网络编程
- 【Flink】CSV 文件写入 追加写入 CsvWriter 的使用
- HACMP环境修改IP的方法
- Java EE体系概述
- [已送完]赠送Google Wave 邀请码
- ubuntu 22.04 安装网易云音乐
- 没有U盘纯硬盘安装linux之manjaro
- LiveGBS流媒体平台GB/T28181常见问题-海康大华宇视监控设备安防摄像头等设备注册不上来如何检查问题?
- 大学英语综合教程四 Unit 7 课文内容英译中 中英翻译
- 我的软件开发方法论2:复利方法观
- python上传数据到坚果云_坚果云功能
- DHCP Relay 配置教程
- Nodejs ORM Prisma 介绍