0

What I am trying to do is set a value in a variable contained within another class.

this is how I am currently trying to achieve it.

BookingUI Class

private void setCarRegNo() 
{
   aBooking.setCarRegNo();
}

Booking class

public void setCarRegNo(String regNo)
{
    carRegNo = regNo;
}

Yet I keep getting an error saying 'setCarRegNo (java.lang.String) in booking cannot be applied to ()

What is it I am doing wrong? Many thanks

4 Answers 4

2

You need to pass a String into the setCarRegNo(String ) of Booking class. The method signature declares that it requires a String argument, and your compiler will complain if you dont supply one.

Sign up to request clarification or add additional context in comments.

Comments

1

You have to pass a string into the setCarRegNo() function. Like this: setCarRegNo("Some string");

Comments

1

In your Booking Class, setCarRegNo takes a single parameter of type String.

When you call it from BookingUI, you are not passing in any parameters.

You need to change BookingUI to something like:

private void setCarRegNo() 
{
   aBooking.setCarRegNo("CarRegNo");
}

Comments

0

you need to pass a string to your setter. change

 aBooking.setCarRegNo();

to

  aBooking.setCarRegNo("the registration number');

as a note, you should fully spell out the words of the variables.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.