我正在尝试调用构造函数返回方法中的结果
//constructor 2
/**
* @param parker the car that is parked
* @param parkee the parking meter reading the car
*/
private ParkingTicket( Car parker, ParkingMeter parkee){
//retrieves the values for license plate, minutes parked, and minutes parked in the class
this(parker.getLicensePlate(),
parker.getMinutesParked(),
parkee.getMinutesPaid()
);
}
这是我试图返回构造函数的方法。 如果停车时间超过支付的分钟数,我想创建一张新的停车票。
//checks if a parking ticket will be issued
public static Integer checkParking(){
//creates a static method of the minutesPaid non-static method
//from the ParkingMeter class
ParkingMeter parkingMeter = new ParkingMeter();
parkingMeter.getMinutesPaid();
//creates a static method of the minutesParked non-static method
//from the Car class
Car car = new Car();
car.getMinutesParked();
if (parkingMeter.getMinutesPaid() > car.getMinutesParked()){
new ParkingTicket( parker, parkee);}
else return null;
}