0

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).

Edited by mike_2000_17: Fixed formatting

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Kratoswoo
0

Yea see i added a random fine = 125 - 60;

Deleted that. Dont knwo why that was there.

Edited by Kratoswoo: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.