I see so many examples everywhere and none of them helped me fix these problems, so if anyone can help me I would greatly appreciate it. I have explained my errors in the red Highlighted sections in comment form....
package lab41thestockclass;
class ParkedCar
{
private String make;
private String model;
private String color;
private String licnum;
public int minparked;
//private double currentPrice;
public ParkedCar(String mk, String mod, String col, String lic, int min)
{
mk = make;
mod = model;
col = color;
lic = licnum;
min = minparked;
}
public ParkedCar(ParkedCar car2)
{
make = car2.make;
model = car2.model;
color = car2.color;
licnum = car2.licnum;
minparked = car2.minparked;
}
public String getMake()
{
return make;
}
public String getModel()
{
return model;
}
public String getColor()
{
return color;
}
public String licnumber()
{
return licnum;
}
public int minparked()
{
return minparked;
}
public void setMake(String make)
{
this.make = make;
}
public void setModel(String model)
{
this.model = model;
}
public void setColor(String color)
{
this.color = color;
}
public void setLicnum(String licnum)
{
this.licnum = licnum;
}
public void setMinParked(int minparked)
{
this.minparked = minparked;
}
}//end ParkedCar class
class ParkingMeter
{
public int minutesPurchased;
public ParkingMeter(int m)
{
m = minutesPurchased;
}
public void setMinutesPurchased(int minutesPurchased)
{
this.minutesPurchased = minutesPurchased;
}
public int getMinutesPurchased()
{
return minutesPurchased;
}
}//end ParkingMeter class
class ParkingTicket
{
private ParkedCar car;
private PoliceOfficer officer;
private double fine;
private int minutes;
private double BASE_FINE = 25.00;
private double HOURLY_FINE = 10.00;
int temp;
public void CalcFine(int m, double newFine)
{
// Determine whether the car is illegally parked.
if (ParkedCar.minparked > ParkingMeter.minutesPurchased)
/*non static variable error here ^^*/
// Determine the amount of the fine.
if (ParkedCar.minparked - ParkingMeter.minutesPurchased <= 60)
/*non static variable error here ^^*/
fine = BASE_FINE;
else
fine = BASE_FINE + (10 * ((ParkedCar.minparked - ParkingMeter.minutesPurchased) / 60));
/*non static variable error here ^^*/
// Create a ParkingTicket object, passing
// 3 objects as arguments to the constructor.
parkingticket = new ParkingTicket(fine, parkedcar, parkingmeter);
/*cannot find symbol error here*/
}
public ParkingTicket(ParkedCar aCar, PoliceOfficer aOfficer, int min)
{
aCar = car;
aOfficer = officer;
min = minutes;
}
public ParkingTicket(double newFine)
{
fine = newFine;
}
public ParkedCar getCar()
{
return car;
}
public PoliceOfficer getOfficer()
{
return officer;
}
public double getFine()
{
return fine;
}
public int getMinutes()
{
return minutes;
}
public double getBASE_FINE()
{
return BASE_FINE;
}
public double getHOURLY_FINE()
{
return HOURLY_FINE;
}
public ParkedCar setCar(String ParkedCar)
{
this.car = new ParkedCar(car);
return car; /*doesn't show an error when i add this to each one from here to
setHOURLY_FINE*/
}
public PoliceOfficer setOfficer(String PoliceOfficer)
{
this.officer = new PoliceOfficer(officer);
return officer;
}
public double setFine()
{
this.setFine();
//getting an error saying missing return statement
}
public int setMinutes()
{
this.setMinutes();
//getting an error saying missing return statement
}
public double setBASE_FINE()
{
this.setBASE_FINE();
//getting an error saying missing return statement
}
public double setHOURLY_FINE()
{
this.setHOURLY_FINE();
//getting an error saying missing return statement
}
public String toString()
{
// Create a string representing the object.
String str = "Illegally parked car info: " + car + "\nParking meter info:" + minutes + "\nAmount of the fine...: " + fine;
//"\nPolice officer info: " + policeofficer;
// Return the string.
return str;
}
}//end ParkingTicket class
class PoliceOfficer
{
private String name;
private String badgeNumber;
public PoliceOfficer(String pname, String bnum)
{
pname = name;
bnum = badgeNumber;
}
public PoliceOfficer(PoliceOfficer officer2)
{
name = officer2.name;
badgeNumber = officer2.badgeNumber;
}
partrol(ParkedCar ParkingMeter){
/*supposed to get car from ParkedCar
meter from ParkingMeter
but not sure what to put here*/
}
}//end PoliceOfficer class
class Main
{
public static void main(String[] args)
{
//create a ParkedCar object.
//The car was parked for 125 minutes..
ParkedCar car = new ParkedCar("Volkswagen","1972","Red","147RHZM", 125);
//Create a ParkingMeter Objec.60 minutes were purchased.
ParkingMeter meter = new ParkingMeter(60);
//Create a PoliceOfficer object.
PoliceOfficer officer = new PoliceOfficer("Joe Friday","4788");
//Let Officer partrol.
ParkingTicket ticket = officer.patrol(car,meter);
//cannot find symbol
//symbol somthing about officer.patrol(car,meter)
//Did the officer issue a ticket?
if(ticket != null)
System.out.println(ticket);
else
System.out.println("No Crimes Were Committed");
}
}