-
newbie question on void method
I just started learning java and this is part of my assignment.
I was trying to allow my interface to run the the openAccount method. But it
seems that I keep getting this error java:60:
Customer(java.lang.String,java.lang.String,java.lang.String,int,java.lang.St
ring) in Customer cannot be applied to ()
Customer customer = new Customer();
Part of my interface code is :
public void AccBalance() throws IOException{
BufferedReader in = new BufferedReader
(new InputStreamReader(System.in));
boolean done = false;
while(!done) {
System.out.println("Account Balance");
System.out.println(" [O] Opening Account ");
System.out.println(" [C] Closing Account ");
System.out.println(" [D] Display Account ");
System.out.println(" [R] Return To The Menu ");
System.out.println(" ");
System.out.print("Enter your selection (O, C, D or R) : ");
System.out.flush();
String option = in.readLine();
System.out.println("");
//Go according to their options for O, C, D or R
if(option.equalsIgnoreCase("o")) {
//System.out.println("o");
Customer customer = new Customer(); ==> error, it seems that it can't
openaccounts as the customer obj has no value
customer.openAccounts();
Inside my customer class, I have declared the customer instances variable
and constructor. For example,
public class Customer extends Account
{
private String custID;
Customer(String custID)
{
this.custID = custID;
}
public static void openAccounts() throws IOException
{
System.out.print("Enter your customer id: ");
// open up standard input
BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
String custid = null;
// read the username from the command-line; need to use try/catch with
the
// readLine() method
try {
custid = a.readLine();
} catch (IOException ioe) {
System.out.println("IO error trying to read your name!");
System.exit(1);
}
System.out.println("Thanks for the customer id, " + custid);(==> I thought
this will be store in the memory as custid ..so by right they should be able
to see in cust obj
}
can someone help me to point out how to go about it and get rid of the
error?Or give me some example to enlighten me? Thanks a lot..
-
60:
Customer(java.lang.String,java.lang.String,java.lang.String,int,java.lang.St
ring) in Customer cannot be applied to ()
Customer customer = new Customer();
deciphered: on line 60 of your code
you are attempting to use Customer's constructor, but you are not giving all the required arguments..
in fact, youre giving no arguments at all, when a customer NEEDS the following:
a string
a string
a string
an int
a string
what these are, i dont know, but you cannot create a new customer object without them, hence the message: method(argument1, argument2...) cannot be applied to method()
-
an analogy might be your mum saying to you "go"
you say go where?
you understand how to go, but you need a destination, or a purpose
what she actually wanted you to do was go to the shop and buy a loaf of bread.. but how could you know his, when she just said "go"
youre jsut saying new Customer.. but youre not telling the compiler things it definitely needs to know, to carry out your bidding
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks