Im trying to do this code to create a Parking ticket Simulator. This is the code.
public class Parking_Ticket
{
private String make;
private String model;
private String color;
private String licenseNumber;
public int minutes;
public class ParkedCar
{
private String make;
private String model;
private String color;
private String licenseNumber;
public int minutes;
public ParkedCar(String mk, String mod, String col, String lic, int min)
{
make = mk;
model = mod;
color = col;
licenseNumber = lic;
minutes = min;
}
public ParkedCar(ParkedCar car2)
{
make = car2.make;
model = car2.model;
color = car2.color;
licenseNumber = car2.licenseNumber;
minutes = car2.minutes;
}
public String toString()
{
String str = "Parked car's make.....................: " + make +
"\nParked car's model..................: " + model +
"\nParked car's color..................: " + color +
"\nParked car's license plate number...: " + licenseNumber +
"\nMinutes that the car has been parked: " + minutes;
return str;
}
}
public class ParkingMeter
{
public void ParkingMeter(int m)
{
}
public void setMinutesPurchased(int m)
{
}
public int getMinutesPurchased()
{
return minutes;
}
}
public class ParkingTicket
{
private ParkedCar car;
private PoliceOfficer officer;
private double fine;
double BASE_FINE = 25.0;
double HOURLY_FINE = 10.0;
public ParkingTicket(ParkedCar aCar, PoliceOfficer anOfficer, int min)
{
car = aCar;
officer = anOfficer;
fine = min;
}
public ParkingTicket(ParkingTicket ticket2)
{
car = ticket2.car;
officer = ticket2.officer;
fine = ticket2.fine;
}
public void calculateFine()
{
fine = 125 - 60;
}
public String toString()
{
String str = "Illegally parked car info: " + car +
"\nAmount of the fine...: " + fine +
"\nPolice officer info: " + officer;
return str;
}
}
public class PoliceOfficer
{
private String name;
private String badgeNumber;
public PoliceOfficer(String n, String bn)
{
}
public ParkingTicket patrol(ParkedCar car, ParkingMeter meter)
{
return null;
}
public String toString()
{
String str = "Badge Number: " + badgeNumber +
"\nPolice officer Name: " + name;
return str;
}
}
public static void main(String[] args)
{
ParkedCar car = new ParkedCar("Volkswagen", "1972","Red","147RHZM", 125);
ParkingMeter meter = new ParkingMeter();
PoliceOfficer officer = new PoliceOfficer("Joe Friday", "4788");
ParkingTicket ticket = officer.patrol(car, meter);
if(ticket != null)
System.out.println(ticket);
else
System.out.println("No crimes committed!");
}
}
The problem im getting is
No enclosing instance of type Parking_Ticket is accessible. Must qualify the allocation with an enclosing instance of type Parking_Ticket (e.g. x.new A() where x is an instance of Parking_Ticket).
No enclosing instance of type Parking_Ticket is accessible. Must qualify the allocation with an enclosing instance of type Parking_Ticket (e.g. x.new A() where x is an instance of Parking_Ticket).
No enclosing instance of type Parking_Ticket is accessible. Must qualify the allocation with an enclosing instance of type Parking_Ticket (e.g. x.new A() where x is an instance of Parking_Ticket).