943,922 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 1085
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
May 11th, 2009
0

Need help with my Java Programming

Expand Post »
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
  • 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.
Attached Files
File Type: java ParkedCar.java (1.5 KB, 20 views)
File Type: java ParkingMeter.java (793 Bytes, 8 views)
File Type: java ParkingTicket.java (1.5 KB, 15 views)
File Type: java PoliceOfficer.java (2.0 KB, 13 views)
File Type: java MeterTest.java (667 Bytes, 12 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TaubBaer is offline Offline
10 posts
since Apr 2009
May 11th, 2009
0

Re: Need help with my Java Programming

Ok, so you were able to post your homework, but how about explaining what the problem is you're having?
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004
May 11th, 2009
0

Re: Need help with my Java Programming

Click to Expand / Collapse  Quote originally posted by Phaelax ...
Ok, so you were able to post your homework, but how about explaining what the problem is you're having?
Updated: In the ParkingMeter, I put "//" in this line which gave me an less error.
	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)
  1. MeterTest.java:19: cannot find symbol
  2. symbol : constructor PoliceOfficer(java.lang.String,int,ParkedCar,ParkingMeter)
  3. location: class PoliceOfficer
  4. PoliceOfficer cop = new PoliceOfficer("Raby", 1234, car, meter);
  5. ^
  6. MeterTest.java:20: cannot find symbol
  7. symbol : method inspectParkedCar()
  8. location: class PoliceOfficer
  9. cop.inspectParkedCar();
  10. ^
  11. MeterTest.java:21: cannot find symbol
  12. symbol : variable fine
  13. location: class PoliceOfficer
  14. ParkingTicket ticket = new ParkingTicket(cop.fine, car, meter);
  15. ^
  16. MeterTest.java:21: internal error; cannot instantiate ParkingTicket.<init> at ParkingTicket to ()
  17. ParkingTicket ticket = new ParkingTicket(cop.fine, car, meter);
  18. ^
  19. MeterTest.java:22: cannot find symbol
  20. symbol : class ParkigTicket
  21. location: class MeterTest
  22. ParkigTicket ticket = cop.ticket(car, meter);
  23. ^
  24. MeterTest.java:22: ticket is already defined in main(java.lang.String[])
  25. ParkigTicket ticket = cop.ticket(car, meter);
  26. ^
  27. MeterTest.java:24: cannot find symbol
  28. symbol : variable myticket
  29. location: class MeterTest
  30. if(myticket != null)
  31. ^
  32. 7 errors
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TaubBaer is offline Offline
10 posts
since Apr 2009
May 11th, 2009
0

Re: Need help with my Java Programming

For the first error, you're either using a constructor that does not exist, or you didn't properly import the class.
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008
May 11th, 2009
0

Re: Need help with my Java Programming

For the first error, you're either using a constructor that does not exist, or you didn't properly import the class.
How do I solve this problem?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TaubBaer is offline Offline
10 posts
since Apr 2009
May 11th, 2009
0

Re: Need help with my Java Programming

Click to Expand / Collapse  Quote originally posted by TaubBaer ...
How do I solve this problem?
Use a constructor that DOES exist or import the class. In your case, it's the former. Here are your constructors:

Java Syntax (Toggle Plain Text)
  1. public PoliceOfficer()
  2. public PoliceOfficer(String on, int bn, ParkedCar pc, ParkingMeter pm, ParkingTicket ticket)
  3. public PoliceOfficer(PoliceOfficer original)

Here's your error:

Quote ...
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);
None of your constructors take four arguments. The closest is this:
Java Syntax (Toggle Plain Text)
  1. 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.

Quote ...
MeterTest.java:22: cannot find symbol
symbol : class ParkigTicket
location: class MeterTest
ParkigTicket ticket = cop.ticket(car, meter);
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008
May 11th, 2009
0

Re: Need help with my Java Programming

I fixed some errors but still having problems... I looked at all objects and am still having problems.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TaubBaer is offline Offline
10 posts
since Apr 2009
May 11th, 2009
0

Re: Need help with my Java Programming

Will it be easy for you if I post the classes instead attachments?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TaubBaer is offline Offline
10 posts
since Apr 2009
May 11th, 2009
0

Re: Need help with my Java Programming

Click to Expand / Collapse  Quote originally posted by TaubBaer ...
Will it be easy for you if I post the classes instead attachments?
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.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008
May 11th, 2009
0

Re: Need help with my Java Programming

Sure... I had been changing some of classes... I think I am getting there now. Let me zip all 5 files and attach it here.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TaubBaer is offline Offline
10 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Need to display multiple images from database on a webpage.
Next Thread in Java Forum Timeline: java unscrambler





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC