0

I am writing a class for a program where now I need to add a method for coming up with a late fee cost. This is between movie genre's with each genre costing something different but for the one I will use here will be the Drama genre which has the default late fee (That variable is in a different class, also the dayLate variable is in another class as well)

Anyway what I need to do is make it so that the method adds it up like the number of days late multiplied by the fee. Right now I have this but I get a compiler error (Also if it matters, the class with the dayLate variable is not yet finished or compiled)

Anyway here is the Drama class source code

class Drama extends Movie { public Drama() { super(); } public Drama(String rating, int IDnumber, String MovieTitle) { super(rating, IDnumber, MovieTitle); } public double CalcLateFees(Fee * dayLate); } 

I don't think I did this method correct though.

4 Answers 4

1

You cannot write your logic in the method's prototype, instead you should receive the values as the parameter and do the logic and return the values like below:

public double CalcLateFees(double fee, double dayLate) { return (fee * dayLate); } 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I think that's what I need to do, put the double in front of it although my dayLate is type int (Sorry I didn't show that part) It's getting late so I'll have to try this tomorrow. Thanks
0

Java doesn't use pointer just uses reference

So change this

public double CalcLateFees(Fee * dayLate); 

to

public double CalcLateFees(Fee dayLate); 

Also make sure Movie class has default const and const with (String rating, int IDnumber, String MovieTitle) arguments

1 Comment

I don't think he was trying to use a pointer, but calculating in the signature of the method.
0

Favor composition over inheritance. Try having a genre property in the movie class. The genre class can hold a fee member.

Comments

0

switch (yourChoice) {

case 1: Implement your CalclateFees method some how:

public double CalcLateFees(Fee dayLate) { double fee = 0; .... return fee; } 

case 2: Declare your CalclateFees method as abstract:

public abstract double CalcLateFees(Fee dayLate); 

case 3: Let the Fee class handle the caculation:

public double CalcLateFees(Fee dayLate) { return dayLate.calc(this); } 

}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.