Need help with my Java Programming

Thread Solved

Join Date: Apr 2009
Posts: 10
Reputation: TaubBaer is an unknown quantity at this point 
Solved Threads: 0
TaubBaer TaubBaer is offline Offline
Newbie Poster

Need help with my Java Programming

 
0
  #1
May 11th, 2009
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, 3 views)
File Type: java ParkingMeter.java (793 Bytes, 2 views)
File Type: java ParkingTicket.java (1.5 KB, 6 views)
File Type: java PoliceOfficer.java (2.0 KB, 3 views)
File Type: java MeterTest.java (667 Bytes, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: Need help with my Java Programming

 
0
  #2
May 11th, 2009
Ok, so you were able to post your homework, but how about explaining what the problem is you're having?
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: TaubBaer is an unknown quantity at this point 
Solved Threads: 0
TaubBaer TaubBaer is offline Offline
Newbie Poster

Re: Need help with my Java Programming

 
0
  #3
May 11th, 2009
Originally Posted by Phaelax View Post
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:
  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
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,568
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 196
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso

Re: Need help with my Java Programming

 
0
  #4
May 11th, 2009
For the first error, you're either using a constructor that does not exist, or you didn't properly import the class.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: TaubBaer is an unknown quantity at this point 
Solved Threads: 0
TaubBaer TaubBaer is offline Offline
Newbie Poster

Re: Need help with my Java Programming

 
0
  #5
May 11th, 2009
Originally Posted by BestJewSinceJC View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,813
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Need help with my Java Programming

 
0
  #6
May 11th, 2009
Originally Posted by TaubBaer View Post
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:

  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:

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

MeterTest.java:22: cannot find symbol
symbol : class ParkigTicket
location: class MeterTest
ParkigTicket ticket = cop.ticket(car, meter);
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: TaubBaer is an unknown quantity at this point 
Solved Threads: 0
TaubBaer TaubBaer is offline Offline
Newbie Poster

Re: Need help with my Java Programming

 
0
  #7
May 11th, 2009
I fixed some errors but still having problems... I looked at all objects and am still having problems.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: TaubBaer is an unknown quantity at this point 
Solved Threads: 0
TaubBaer TaubBaer is offline Offline
Newbie Poster

Re: Need help with my Java Programming

 
0
  #8
May 11th, 2009
Will it be easy for you if I post the classes instead attachments?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,813
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Need help with my Java Programming

 
0
  #9
May 11th, 2009
Originally Posted by TaubBaer View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: TaubBaer is an unknown quantity at this point 
Solved Threads: 0
TaubBaer TaubBaer is offline Offline
Newbie Poster

Re: Need help with my Java Programming

 
0
  #10
May 11th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC