CSDN 和電驢上有很多案例的,直接搜就可以找到了,數(shù)據(jù)庫(kù)都帶上了
成都創(chuàng)新互聯(lián)公司長(zhǎng)期為成百上千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為章丘企業(yè)提供專業(yè)的成都網(wǎng)站制作、網(wǎng)站建設(shè),章丘網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。
參考程序:
public?class?Student?{
private?String?name;
public?String?getName()?{
return?name;
}
public?void?setName(String?name)?{
this.name?=?name;
}
public?void?goHome(Traffic?t){
System.out.println("學(xué)生:"+this.name);
t.run();
}
public?Student(String?name)?{
this.name?=?name;
}
}
public?abstract?class?Traffic?{
protected?double?speed;
public?void?run(){
}
}
public?class?Bus?extends?Traffic{
@Override
public?void?run()?{
System.out.println("時(shí)速為"+super.speed+"公里每小時(shí)的汽車正在嘀嗒嘀嗒的開(kāi)著.");
}
public?Bus(double?busSpeed)?{
super.speed?=?busSpeed;
}
}
public?class?Train?extends?Traffic?{
@Override
public?void?run()?{
System.out.println("時(shí)速為"+super.speed+"公里每小時(shí)的火車正在況且況且的開(kāi)著.");
}
public?Train(double?trainSpeed)?{
super.speed?=?trainSpeed;
}
}
public?class?AirPlan?extends?Traffic?{
@Override
public?void?run()?{
System.out.println("時(shí)速為"+super.speed+"公里每小時(shí)的飛機(jī)正在吳屋吳屋的開(kāi)著.");
}
public?AirPlan(double?airPlanSpeed)?{
super.speed?=?airPlanSpeed;
}
}
public?class?Test?{
public?static?void?main(String[]?args)?{
Traffic?traffic1?=?new?Bus(40);
Student?student?=?new?Student("小明");
student.goHome(traffic1);
Traffic?traffic2?=?new?Train(120);
Student?student2?=?new?Student("小花");
student2.goHome(traffic2);
Traffic?traffic3?=?new?AirPlan(300);
Student?student3?=?new?Student("小紅");
student3.goHome(traffic3);
}
}
java火車票網(wǎng)上訂票系統(tǒng)
java火車票網(wǎng)上訂票系統(tǒng)
可以為你完成這個(gè)題目
MapString,Integer ms=new HashMapString,Integer();
ms.put("A-B", 20);
ms.put("A-C", 30);
ms.put("A-D", 40);
ms.put("A-E", 50);
ms.put("B-C", 60);
ms.put("B-D", 70);
ms.put("B-E", 80);
ms.put("C-D", 90);
ms.put("C-E", 70);
Scanner input=new Scanner(System.in);
System.out.print("輸入出發(fā)站:");
String strA=input.next();
System.out.print("輸入目的站:");
String strB=input.next();
String key=(strA+"-"+strB).toUpperCase();
System.out.println(key+"火車票價(jià)錢是:"+ms.get(key));
這樣?