Help with instantiating a class within a switch statement
Hello everyone, I am not to sure how to go about doing this. What I want to do is instantiate an object from a class and then adjust the values via keyboard input. I think the problem may be that I am trying to adjust the values within switch statements.
Here is the code from the testprogram:
All of the x.sets turn up errors when I compile. Is it possible to Instantiate an object or modify its variables from within switch statements? If it is how would I go about doing that?
public static void main(String args)
Client num1= new Client("11","111",111,111);
Scanner scan = new Scanner(System.in);
System.out.println("Please select from the following menu:");
select = scan.nextInt();
System.out.println("Please enter the Client's Name: ");
name = scan.next();
System.out.println("Please enter the Client's ID Number: ");
id = scan.nextInt();
System.out.println("Please enter the Client's Address: ");
address = scan.next();
System.out.println("Please enter the number of hours worked: ");
hours = scan.nextDouble();
Here is the class that I am using.
public void setClientName(String name)
public void setClientAddress(String address)
public void setClientId(int id)
public void setClientHours(double hours)
public String getClientName()
public String getClientAddress()
public int getClientId()
public double getClientHours()
Thank You in advance
Re: Help with instantiating a class within a switch statement
I'm really not sure what that code is supposed to do. You'll probably want to throw together an SSCCE that demonstrates what you're talking about.