java 商品 系统 代码package entity;
public class Market {
private int id;//id
private int num;//数量
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("您消费共计java买东西代码:"+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("-------超市计价系统-------");
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("请输入商品java买东西代码的编号:");
int num = input.nextInt();
System.out.println("请输入商品的数量");
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; itimes; i++) {
System.out.print(" ");
}
System.out.print(row2);
for (int i = 0; i10; i++) {
System.out.print(" ");
}
System.out.print(row3);
System.out.println("\n");
}
}
//测试结果java买东西代码:
-------超市计价系统-------
编号商品价格
1可口可乐3.0¥
2爆米花5.0¥
3益达10.0¥
请输入商品的编号:
3
请输入商品的数量
5
您消费共计java买东西代码:50.0¥
求简单实现网上商城功能的java代码平时在线10k人大概是让你创建一个数据库连接池,大小设置10k 。
下面是一个图书商城的数据库表部分,供你参考
set utf8
DROP TABLE IF EXISTS d_product;
CREATE TABLE d_product (//用来存放总商品 , 入图书种类
id int(12) NOT NULL auto_increment,
product_name varchar(100) NOT NULL,
description varchar(100) default NULL,
add_time bigint(20) default NULL,
fixed_price double NOT NULL,
dang_price double NOT NULL,
keywords varchar(200) default NULL,
has_deleted int(1) NOT NULL default '0',
product_pic varchar(200) default NULL,
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
【java买东西代码 java电商购物平台代码】INSERT INTO d_product VALUES (23,'上课睡觉的故事','上课睡觉的故事',1237873000234,200,180,'key',0,'15.jpg');
DROP TABLE IF EXISTS d_book;
CREATE TABLE d_book (//用来存放图书的具体内容
推荐阅读
- 钉钉直播怎么解开静音模式,钉钉直播怎么解开静音模式视频
- linux查看显卡命令,查看linux显卡信息
- 宁波公司网站制作,宁波网站公司哪家好
- 淘宝无人直播黑屏,淘宝直播黑屏算挂机吗
- c语言数学函数详解 c语言中的数学函数
- ppt如何裁剪水滴状图片,ppt怎么做水滴
- 虎牙主播直播间跳舞是什么,虎牙直播跳舞最好的
- php自动创建数据库 php 创建数据库
- h5css3app开发,h5开发app