CSDN 和电驴上有很多案例的,直接搜就可以找到了,数据库都带上了
成都创新互联公司长期为成百上千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为章丘企业提供专业的成都网站制作、网站建设,章丘网站改版等技术服务。拥有十年丰富建站经验和众多成功案例,为您定制开发。
参考程序:
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("学生:"+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("时速为"+super.speed+"公里每小时的汽车正在嘀嗒嘀嗒的开着.");
}
public Bus(double busSpeed) {
super.speed = busSpeed;
}
}
public class Train extends Traffic {
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的火车正在况且况且的开着.");
}
public Train(double trainSpeed) {
super.speed = trainSpeed;
}
}
public class AirPlan extends Traffic {
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的飞机正在吴屋吴屋的开着.");
}
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火车票网上订票系统
java火车票网上订票系统
可以为你完成这个题目
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("输入出发站:");
String strA=input.next();
System.out.print("输入目的站:");
String strB=input.next();
String key=(strA+"-"+strB).toUpperCase();
System.out.println(key+"火车票价钱是:"+ms.get(key));
这样?