我被分配使用类和构造函数编写一个小程序,但似乎被卡住了。继承我的代码:
public static class ParkingMeter {
int hours;
int minutes;
public ParkingMeter(int hours,int minutes){
String time = Integer.toString(getMinutes(hours,minutes));
}
private int getMinutes(int hours, int minutes){
int time = (hours * 60) + minutes;
return time;
}
}
public static class ParkedCar{
String CompanyName; // Company name
String Model; // Car model
String Color; // Car color
String PlateNumber; // License plate number
String Minutes; // number of minutes parked
public ParkedCar(String companyName, String model, String color,String plate, String minutes){
CompanyName = companyName;
Model = model;
Color = color;
PlateNumber = plate;
Minutes = minutes;
}
}
public static class PoliceOfficer{
String OfficerName;
String BadgeNumber;
public PoliceOfficer(String name,String badge){
OfficerName = name;
BadgeNumber = badge;
}
public static void checkTheCar(ParkedCar, ParkingMeter){
// do something
}
}
我必须将这些类传递给位于PoliceOfficer class
内的方法,但我收到错误<identifier> expected
。不知道我在这里做错了什么。
谢谢。
答案 0 :(得分:4)
您应该为变量命名。
SidenavService