求大神赐教
main
import java.util.Scanner;
public class text {
public static void main(String[] args) {
car car1=new car(1,"宝马",4,400);//为什么写成dada car1=new car(1,"宝马",4,400);就报错
truck truck1=new truck(2,"景龙",2000,500);
pickup pickup1=new pickup(3,"皮卡",4,1000,600);
System.out.println("欢迎使用哒哒租车系统!");
// TODO Auto-generated method stub
System.out.println("你是否要租车?是1,否0");
Scanner in = new Scanner(System.in);
int i = in.nextInt();
if(i==0){
System.out.println("欢迎下次光临!") ;
}
else{
System.out.println("你可以租车的类型及其价目表:");
System.out.println("序号 "+"汽车 "+"容量 "+"租金 ");
car1.getcar();
truck1.gettruck();
pickup1.getpickup();
System.out.println("请输入你想租借的车序号");
Scanner or = new Scanner(System.in);
int order = in.nextInt();
System.out.println("请输入你想租借天数");
Scanner nu = new Scanner(System.in);
int number = in.nextInt();
switch(order){
case 1: System.out.println("总费用为:"+400*number);break;
case 2: System.out.println("总费用为:"+500*number);break;
case 3: System.out.println("总费用为:"+600*number);break;
}
}
}
}
dada类
public class dada {
String name;
int rent;
int people;
int goods;
int order;
public int getpeople(){
return people;
}
public int getgoods() {
return goods;
}
public String getname() {
return name;
}
public int getrent() {
return rent;
}
public int getorder() {
return order;
}
}
car类
public class car extends dada {
public car(int o,String n,int p,int r ){
order=o;
name=n;
people=p;
rent=r;
}
public void getcar(){
System.out.println(order+" "+name+" "+people+" "+rent+" ");
}
}
pickup类
public class pickup extends dada {
public pickup(int o,String n,int g,int p,int r ){
order=o;
name=n;
goods=g;
people=p;
rent=r;
}
public void getpickup(){
System.out.println(order+" "+name+" "+goods+"/"+people+" "+rent+" ");
}
}
truck类
public class truck extends dada {
public truck(int o,String n,int g,int r ){
order=o;
name=n;
goods=g;
rent=r;
}
public void gettruck(){
System.out.println(order+" "+name+" "+goods+" "+rent+" ");
}
}