| | |
Need help with my Java Programming
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 10
Reputation:
Solved Threads: 0
I had been creating 5 files and I kept hitting the wall. Hope that you will be able to help me pinpoint the problems. (I am not an programmer by the way.) I had been researching for more details on those problems, no luck.
Enclosed are 5 files that I had created. Hope to hear from you soon because I need to turn them in next week as an final project at my college.
The ParkCar class: This class show simulate a parked car. The class' responsibilities are
The ParkingMeter class: This class should simulate a parking meter. The class' responsibilities are
The ParkingTicket class: This class should simulate a parking ticket. The class' responsibilities are
The PoliceOfficer Class: This class should simulate a plice officer inspecting parked cars. The class' responsibilities are
Enclosed are 5 files that I had created. Hope to hear from you soon because I need to turn them in next week as an final project at my college.
The ParkCar class: This class show simulate a parked car. The class' responsibilities are
- To know the car's make, model, color, license number, and the number of minutes that the car has been parked.
The ParkingMeter class: This class should simulate a parking meter. The class' responsibilities are
- To know the number of minutes of parking times that has been purchased.
The ParkingTicket class: This class should simulate a parking ticket. The class' responsibilities are
- To report the make, model, color, and license number of the illegally parked car.
- To report the amount of the fine, which is $25 for the first hour or part of an hour that the car is illegally parked, plus $10 for every additional our or part of an hour that the car is illegally parked.
- To report the name and badge number of the police officer issuing the ticket
The PoliceOfficer Class: This class should simulate a plice officer inspecting parked cars. The class' responsibilities are
- To know the police officer's name and badge number.
- To examine a ParkedCar object and a ParkingMeter object, and determine whether the car's time has expired.
- To issue a parking ticket (generate a ParkingTicket object) if the car's time has expired.
•
•
Join Date: Apr 2009
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
Ok, so you were able to post your homework, but how about explaining what the problem is you're having?
public void inspectParkedCar(int cm, int pm, int mins)
{
cm = car.getParkedMinutes();
pm = meter.getPurchasedMinutes();
mins = cm - pm;
if (mins < 0)
if (mins > 0 && mins <= 60)
fine = 25;
else
fine = 25 + ((10 * mins) / 60);
//ParkingTicket ticket= ParkingTicket(fine, car, meter);
}Copied and pasted from jGRASP:
Java Syntax (Toggle Plain Text)
MeterTest.java:19: cannot find symbol symbol : constructor PoliceOfficer(java.lang.String,int,ParkedCar,ParkingMeter) location: class PoliceOfficer PoliceOfficer cop = new PoliceOfficer("Raby", 1234, car, meter); ^ MeterTest.java:20: cannot find symbol symbol : method inspectParkedCar() location: class PoliceOfficer cop.inspectParkedCar(); ^ MeterTest.java:21: cannot find symbol symbol : variable fine location: class PoliceOfficer ParkingTicket ticket = new ParkingTicket(cop.fine, car, meter); ^ MeterTest.java:21: internal error; cannot instantiate ParkingTicket.<init> at ParkingTicket to () ParkingTicket ticket = new ParkingTicket(cop.fine, car, meter); ^ MeterTest.java:22: cannot find symbol symbol : class ParkigTicket location: class MeterTest ParkigTicket ticket = cop.ticket(car, meter); ^ MeterTest.java:22: ticket is already defined in main(java.lang.String[]) ParkigTicket ticket = cop.ticket(car, meter); ^ MeterTest.java:24: cannot find symbol symbol : variable myticket location: class MeterTest if(myticket != null) ^ 7 errors
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
Use a constructor that DOES exist or import the class. In your case, it's the former. Here are your constructors:
Here's your error:
None of your constructors take four arguments. The closest is this:
You do not pass it a ParkingTicket object. Hence the error.
The errors say exactly what's wrong and even point to exactly what's wrong. Read them carefully. Spelling counts.
Java Syntax (Toggle Plain Text)
public PoliceOfficer() public PoliceOfficer(String on, int bn, ParkedCar pc, ParkingMeter pm, ParkingTicket ticket) public PoliceOfficer(PoliceOfficer original)
Here's your error:
•
•
•
•
MeterTest.java:19: cannot find symbol
symbol : constructor PoliceOfficer(java.lang.String,int,ParkedCar,ParkingMeter)
location: class PoliceOfficer
PoliceOfficer cop = new PoliceOfficer("Raby", 1234, car, meter);
Java Syntax (Toggle Plain Text)
public PoliceOfficer(String on, int bn, ParkedCar pc, ParkingMeter pm, ParkingTicket ticket)
You do not pass it a ParkingTicket object. Hence the error.
The errors say exactly what's wrong and even point to exactly what's wrong. Read them carefully. Spelling counts.
•
•
•
•
MeterTest.java:22: cannot find symbol
symbol : class ParkigTicket
location: class MeterTest
ParkigTicket ticket = cop.ticket(car, meter);
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
It's not a bad idea to post a zip file with all the java files, and in addition you can post/describe any changes and current problems. If you post the zip file, it's a quick download, then we can unzip it as is and compile it rather than a whole bunch of cut and pastes and there's less to keep track of. Post the line itself as well as the error message and a description.
![]() |
Similar Threads
- Please rate my Java programming forums (Website Reviews)
- Java Programming Classes (Java)
- Java Programming Help!!!!!!!!!!!!!!!!! (Java)
- Java as a programming platform. (Java)
- Java Programming (Java)
- java programming language (Java)
Other Threads in the Java Forum
- Previous Thread: Need to display multiple images from database on a webpage.
- Next Thread: java unscrambler
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class client code compile compiler component database developmenthelp eclipse error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide image int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loops mac main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying number online pearl problem program programming project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor






