• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

My Assignment Task

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UML Diagram : refer attachment.

Output :
Welcome Mr. Lim,  You are a member
Your Member Fee : RM12.00
You will get free parking for the first two hours,
Your Car Detail : WWW999
Your Parking duration : 2 hours
Your Parking Payment : Rm 0.00

Welcome Sarah Ali,  You are not a member
You will be charged RM 50.00 for parking more than 20 hours
Your Car Detail : JQA101
Your Parking duration : 2 hours
Your Parking Payment : Rm 3.00



the question :

2. Write the abstract method to fulfill the following requirements.
a) Based on the CustomerApp class in  Figure C2, write the codes for displayInfo() method that will call displayCharges() and getCarInfo()  to display the output as in Figure C3.
b) Write the codes for calcParking() method that will call calcParkingHour() method to convert the total parking hour durations from minutes to hours.  Calculate the parking charges for each customer based on the criteria as follows:


Member No charge for the first 2 hours, and RM1.00 for every other parking hour.
Example : 85 minutes ; 2 hours, Parking Charged is RM0.00
                340 minutes; 6 hours, Parking Charged is RM4.00
Regular Customer RM1.50 for every hour parked and RM50.00 if the car has been parked for 20 hours or more.
Example : 85 minutes; 2 hours, Parking Charged is RM3.00
                340 minutes, 6 hours, Parking Charged is RM9.00


my code :


exam.jpg
[Thumbnail for exam.jpg]
 
Saloon Keeper
Posts: 9747
80
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
 
Charlie-s Brown
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the asignment question is in there :

2. Write the abstract method to fulfill the following requirements.
a) Based on the CustomerApp class in  Figure C2, write the codes for displayInfo() method that will call displayCharges() and getCarInfo()  to display the output as in Figure C3.
b) Write the codes for calcParking() method that will call calcParkingHour() method to convert the total parking hour durations from minutes to hours.  Calculate the parking charges for each customer based on the criteria as follows:

Member No charge for the first 2 hours, and RM1.00 for every other parking hour.
Example : 85 minutes ; 2 hours, Parking Charged is RM0.00
               340 minutes; 6 hours, Parking Charged is RM4.00
Regular Customer RM1.50 for every hour parked and RM50.00 if the car has been parked for 20 hours or more.
Example : 85 minutes; 2 hours, Parking Charged is RM3.00
               340 minutes, 6 hours, Parking Charged is RM9.00



So i already write the code, but it get to many errors and I stuck at error line 32.
Can help me resolved all error and get the output needed?
 
Carey Brown
Saloon Keeper
Posts: 9747
80
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you get an error cut and past the entire error message into a post, it usually contains information helpful in finding the problem.
 
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
line 34 looks wrong to me. but yes, post your errors.
 
Charlie-s Brown
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



the error :
error.jpg
[Thumbnail for error.jpg]
 
Sheriff
Posts: 27469
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's just take the first one. A Customer has an array of ParkedCar objects, according to your code. I'm not sure why the design is like that -- when I drive into a parking lot I only have one car with me.

Anyway, Customer then has a constructor which accepts a single ParkedCar object. Clearly you can't assign that to the array, like your code does. But I don't understand what's supposed to happen instead. Is it supposed to be put into the array of ParkedCar objects, or something?
 
S Fox
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
remember i told you i think line 34 looks wrong?
now look at the top of your error log, what does it say about line 34?
it tells you:  ParkedCar cannot be converted to ParkedCar[]
so look at line 34, there's a mistake there. fix it and try to recompile again.
 
S Fox
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm not good with reading those UML documents but i don't see anything about an array in there. i think having an array was a mistake and not an intended part of the design?
 
Paul Clapham
Sheriff
Posts: 27469
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also: it's possible to copy and paste from the Windows command prompt. Here's how:

The icon at the top left corner has a menu hidden in it. Click on it, then move the mouse down to the Edit option and select Mark from it. Then press Control-A to select everything in the command prompt window. (Or you can drag the mouse over the window to select less than that.) Finally, use the Edit option of the menu again and select Copy from it. Then the text from the selection goes into the clipboard and you can paste it into your post here.

It's easier to deal with text rather than images when you're talking about compiler error messages. You can search through the text in the browser, you can select bits of it with your mouse, and so on.

 
Bartender
Posts: 1899
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a couple quick things:

1. You have classes that implement the Chargeable interface so you need to implement that displayCharges() method in those classes.

2. Abstract methods cannot have a method body (see your public abstract displayInfo()).

---

If you step through your code in a good IDE in debug mode, you'll get lots of help cleaning up your code.

HOPE THIS HELPS.

- mike
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic