算是最簡(jiǎn)單的吧
創(chuàng)新互聯(lián)公司,為您提供重慶網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)站營(yíng)銷推廣、網(wǎng)站開發(fā)設(shè)計(jì),對(duì)服務(wù)成都鑿毛機(jī)等多個(gè)行業(yè)擁有豐富的網(wǎng)站建設(shè)及推廣經(jīng)驗(yàn)。創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)公司成立于2013年,提供專業(yè)網(wǎng)站制作報(bào)價(jià)服務(wù),我們深知市場(chǎng)的競(jìng)爭(zhēng)激烈,認(rèn)真對(duì)待每位客戶,為客戶提供賞心悅目的作品。 與客戶共同發(fā)展進(jìn)步,是我們永遠(yuǎn)的責(zé)任!
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陸菜單 ");
System.out.println("1登陸系統(tǒng)");
System.out.println("2退出");
}
static void choice1() {
System.out.println("購(gòu)物管理系統(tǒng)客戶信息");
System.out.println("1顯示所有客戶信息");
System.out.println("2添加客戶信息");
System.out.println("3修改客戶信息");
System.out.println("4查詢客戶信息");
}
static void choice2() {
System.out.println("購(gòu)物管理系統(tǒng)真情回饋");
System.out.println("1幸運(yùn)大放送");
System.out.println("2幸運(yùn)抽獎(jiǎng)");
System.out.println("3生日問(wèn)候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("請(qǐng)輸入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜單");
System.out.println("1客戶信息管理");
System.out.println("2購(gòu)物結(jié)算");
System.out.println("3真情回饋");
System.out.println("4注銷");
break;
}
System.out.println("選擇輸入數(shù)字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("購(gòu)物結(jié)算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}
package?entity;
public?class?Market?{
private?int?id;//id
private?int?num;//數(shù)量
private?String?goods;//商品
private?double?price;//價(jià)格
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("您消費(fèi)共計(jì):"+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("-------超市計(jì)價(jià)系統(tǒng)-------");
String?goods1="可口可樂(lè)";
String?goods2="爆米花";
String?goods3="益達(dá)";
printTable("編號(hào)","商品","價(jià)格");
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("請(qǐng)輸入商品的編號(hào):");
int?num?=?input.nextInt();
System.out.println("請(qǐng)輸入商品的數(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");
}
}
//測(cè)試結(jié)果:
-------超市計(jì)價(jià)系統(tǒng)-------
編號(hào)????????????商品??????????價(jià)格
1?????可口可樂(lè)??????????3.0¥
2?????爆米花??????????5.0¥
3?????益達(dá)??????????10.0¥
請(qǐng)輸入商品的編號(hào):
3
請(qǐng)輸入商品的數(shù)量
5
您消費(fèi)共計(jì):50.0¥
因?yàn)橛脩艉驮u(píng)論是一對(duì)多關(guān)系,首先需要兩張表:1.用戶表
2.評(píng)論表
struts獲取前臺(tái)傳入的 用戶名(或者登陸后從session獲?。⒃u(píng)論時(shí)間、評(píng)論內(nèi)容組成為類型為Comment的對(duì)象c,調(diào)用一個(gè)service層的方法service.save(Comment c)來(lái)進(jìn)行事務(wù)處理(事務(wù)織入等在xml配置,簡(jiǎn)單的話也可以不配置)。
service層的方法為save(Comment c){
commentDao.save(c);//調(diào)用了數(shù)據(jù)訪問(wèn)層的save方法
}
dao層開始調(diào)用hibernate的save語(yǔ)句,將對(duì)象c持久化。
至于你說(shuō)的impl,是基于抽象編程,降低耦合度。如serviceImpl類的方法要嚴(yán)格遵循service接口的方法體。
網(wǎng)站標(biāo)題:java代碼商品評(píng)價(jià)系統(tǒng) java實(shí)現(xiàn)評(píng)論功能
文章網(wǎng)址:http://muchs.cn/article10/doeesgo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站排名、網(wǎng)站設(shè)計(jì)、標(biāo)簽優(yōu)化、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)