• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginner Question, Multiple Classes  RSS feed

 
James Moriarty
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, I'm currently enrolled in a Java 1 class and I'm extremely frustrated with my teacher. We have an assignment that involves making a bank account system where we can either deposit or withdraw money, depending on user input. Here's my Service Class:



and this is my Client Class:




...after compiling I get this error message: Lab5Client.java:8: error: method enterChoice in class Lab5BankService cannot be applied to given types;

I can't seem to figure out what the problem, I thought I was making the newNumber object in the Client class the same as the number variable in the Service class. I really want to figure out why the program won't compile. It's great if I can figure out the error message, but i also want to learn WHY. Thanks in advance to everyone who helps, I'm trying to learn Java and this teacher of mine is making it extremely difficult. Cheers!

-James
 
Michael Novello
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The enterChoice() method expects you to pass an integer to it.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James / Michael

A warm welcome to the ranch. Use code tags whenever you are referring to some Java code:



Doesn't it look much more neat and clean?


The answer to your query: The signature of your method is expecting an integer to be passed as an argument which you are not. Hence, the compiler is complaining. Understood?

Now you said that you want to learn Java. I would suggest you to grab a copy of "Head First Java" by Kathy Sierra- Bert Bates. It is a very beautifully written book. Surely you shall be able to grasp concepts and burn them in your mind. I don't believe in directly providing solutions to any problem. That goes against the very first principles of having such a forum. If I give you the answer straightaway, it will solve your issue. But you won't learn anything from it. You won't be able to fully appreciate what the others have to offer and you certainly won't have an answer to your "WHY". Devote at least 2 hours daily to studying the book I mentioned. Write small code snippets. Try those out in a good text editor(NOT an IDE) since you are a beginner. Compile code from command prompt. You have some doubts, we are here to help.
 
Ishan Pandya
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@james - use "code tags" to write the code. the error simply describes your problem.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Since you are new, I have added the code tags, and yo ucan see how much better it looks.
You need to go through that enterChoice method carefully. It does not do what you think it does.
 
James Moriarty
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haha, oh goodness the solution is so simple I could probably scream...but I'm in class right now. Anyway, thanks for the code tag advice, that'll help a ton, and also for the book. I'm going to look into it and hopefully pick up a copy soon.

-James
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!