1. 求一套完整的JAVA WEB項目的網路購物網站源代碼
我這里有一套自己寫的仿京東的購物網站,你要嗎?
資料庫你就自己創建吧,然後商品的圖片是varchar類型的,只需要給一個路徑就可以了。
也希望能幫到你,望採納。
2. 用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;
}
}
}
3. 購物車的Java代碼
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;public class ShoppingCartManager {
HashMap<String, String> hm=new HashMap<String, 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 ArrayList<BookBean> getShoppingCart(){
ArrayList<BookBean> al=new ArrayList<BookBean>();
Iterator<String> 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;j<al.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);
}
}
4. 求一個完整的javaweb項目的購物網站源代碼
我這里有幾個完整的javaweb商城,一個是仿當當,一個是仿京東,框架採用springmvc和mybatis
嚴格按照mvc設計模式做的,遠超大學的平均水平了
5. 如何使用java實現京東優惠券的功能
你做頁面,然後登陸到京東網站????還是你模擬京東的登陸頁面?如果是前一種的方式,你永遠也登陸不了,資料庫是京東設計的,第二種方式都是可行的。
6. java抓取網頁優惠券信息那位大神會寫幫忙寫一下,一直取不到,附上鏈接
使用jsoup-1.7.3.jar
importjava.io.IOException;
importorg.jsoup.Jsoup;
importorg.jsoup.nodes.Document;
publicclassCrawler{
publicstaticvoidmain(String[]args)throwsIOException{
版Stringurl="你的url";
Documentdoc=Jsoup.connect(url)
.userAgent("Mozilla/5.0(WindowsNT10.0;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/56.0.2924.87Safari/537.36")
.get();
System.out.println(doc.select("div[class=coupon-info]").text());
}
}
執行結果權:
7. 藍橋杯java試題購物券
|
public class Cal {
private static Integer price[];
private static Integer result[];
private static Integer num;
private static List<Integer[]> list = new ArrayList<Integer[]>();
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String numStr = br.readLine();
num = Integer.parseInt(numStr);
if(num==null||num==0) return;
price = new Integer[num];
result = new Integer[num];
for(int i=0; i<num; i++){
result[i] = 0;
}
for(int i=0; i<num; i++){
price[i] = Integer.parseInt(br.readLine());
}
cal(1000, 0);
System.out.println(list.size());
for(Integer[] resu : list){
for(Integer n : resu){
System.out.print(n+" ");
}
System.out.println();
}
}
public static void cal(int money, int i){
if(money<0)return;
if(i>=num)return;
if(money==0){
Integer[] line = new Integer[num];
for (int j = 0; j < line.length; j++) {
line[j] = result[j];
}
list.add(line);
return;
}
for(;i<num;i++){
result[i]++;
cal(money-price[i], i);
result[i]--;
}
}
}
8. java簡單的購物車代碼
packageTest;
importjava.util.LinkedHashMap;
importjava.util.Map;
importjava.util.Map.Entry;
importjava.util.Scanner;
publicclassTest{
publicstaticvoidmain(String[]args){
init();//初始化
Map<String,String>map=newLinkedHashMap<>();
while(true){
Scannerin=newScanner(System.in);
map=buy(in,map);//選擇
System.out.println();
System.out.println("還要繼續購物嗎?(Y/N)");
Stringjx=in.nextLine();
if(jx.equals("N")){
break;
}
}
print(map);
}
publicstaticvoidprint(Map<String,String>m){
System.out.println("
******************");
System.out.println("購物車清單");
Integerhj=0;
for(Entry<String,String>entry:m.entrySet()){
Stringkey=entry.getKey();
Stringvalue=entry.getValue();
if(key.equals("1")){
hj+=Integer.parseInt(value)*3;
System.out.println("哇哈哈純凈水:"+value+"件,合計:¥"+Integer.parseInt(value)*3);
}elseif(key.equals("2")){
hj+=Integer.parseInt(value)*5;
System.out.println("康師傅方便麵:"+value+"件,合計:¥"+Integer.parseInt(value)*5);
}elseif(key.equals("3")){
hj+=Integer.parseInt(value)*4;
System.out.println("可口可樂:"+value+"件,合計:¥"+Integer.parseInt(value)*4);
}
}
System.out.println("合計金額:¥"+hj);
}
publicstaticvoidinit(){
System.out.println("******************");
System.out.println(" 商品列表
");
System.out.println("商品名稱價格");
System.out.println("1.哇哈哈純凈水¥3");
System.out.println("2.康師傅方便麵¥5");
System.out.println("3.可口可樂¥4");
System.out.println("******************");
}
publicstaticMap<String,String>buy(Scannerscan,Map<String,String>m){
System.out.print("請輸入編號:");
Stringbh=scan.nextLine();
System.out.print("請輸入購買數量:");
Stringnum=scan.nextLine();
if(m.size()>0&&m.keySet().contains(bh)){
m.put(bh,(Integer.parseInt(bh)+Integer.parseInt(num))+"");
}else{
m.put(bh,num);
}
returnm;
}
}
9. 用java編程實現網上超市購物結算功能代碼
哎,我還是自己代碼黏貼給你吧!免得總通不過!裝不下這么多字,詳情自己找我。 連接資料庫類(添加修改會員信息) package com.to.java; import java.util.Scanner; import java.sql.*; public class Vds { Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); public void x(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); System.out.println("----------查詢結果---------"); System.out.println(); System.out.println("會員號--密碼"); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } con.close(); stmt.close(); }catch(Exception e){ System.out.println(e);} System.out.println("是否返回上級菜單"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("歡迎下次再次使用");System.exit(-1);}; break; }} public void j(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("請輸入會員信息:"); System.out.println("請輸入會員號:"); String f=input.next(); System.out.println("請輸入密碼:"); String q=input.next(); String sqlst="insert into gg values('"+f+"','"+q+"')"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上級菜單"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("歡迎下次再次使用");System.exit(-1);}; break; } } public void xg(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("請輸入會員信息:"); System.out.println("請輸入要修改的會員號:"); String f=input.next(); System.out.println("請輸入修改的密碼:"); String q=input.next(); String sqlst="update gg set mm='"+q+"' where id='"+f+"'"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上級菜單"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("歡迎下次再次使用");System.exit(-1);}; break; } } } package com.to.java; import java.util.Scanner; public class KeHu { Vds sj=new Vds(); public void kehu1(){ Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("******************************************************"+"\n\n"); System.out.println("1.顯示所有客戶信息"); System.out.println("2.添加客戶信息"); System.out.println("3.修改客戶信息"); System.out.println("4.查詢客戶信息"); System.out.println("5.返回上級菜單"); System.out.println("******************************************************"+"\n\n"); System.out.println("請輸入數字:"); int a=Input.nextInt(); switch(a){ case 1: sj.x(); break; case 2: sj.j(); break; case 3: sj.xg(); break; case 4: sj.x();break; case 5: zhuck1.ZhucK1();break; } } } package com.to.java; public class GouWuXiTong { public static void main(String[] args){ ZhuCK zhuck=new ZhuCK(); zhuck.ZhucK(); } } package com.to.java; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Scanner; public class ZhuCK { Scanner Input=new Scanner(System.in); public void ZhucK(){ ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("\t\t"+"歡迎使用我心我素購物系統"); System.out.println("******************************************************"+"\n\n"); System.out.println("\t\t"+"1.登陸系統"); System.out.println(); System.out.println("\t\t"+"2.退出"+"\n\n"); System.out.println("******************************************************"); int d=1; while(d!=2){ System.out.println("請輸入會員號:"); String p=Input.next(); System.out.println("請輸入密碼:"); String f=Input.next(); try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select * from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); if(id.equals(p)&&mm.equals(f)){ { System.out.println("請輸入數字:"); int a=Input.nextInt(); switch(a){ case 1: zhuck1.ZhucK1(); break; case 2: break; }d=2; } } } }catch(Exception e){ System.out.println(e);} {System.out.println("輸入錯誤請再次輸入:");d=1;} } }} }