JAVA Help!! Recalling a method in a case/switch statement

jxmetal

Junior Member
Sep 27, 2004
18
0
0
I was wondering how you recall a method for a case/switch statement. Here's the code I need filled in, thank you. The bold words are my methods.

Code:
		switch(CustomerType)
		{
			case 'r':
			case 'R': regularBill;

			System.exit(0);

				      break;

		    case 'p':
		    case 'P': premiumBill;

            System.exit(0);

		    		  break;

		    default: JOptionPane.showMessageDialog(null,"Invalid customer type.","Error",JOptionPane.PLAIN_MESSAGE);

		    System.exit(0);

	}
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: jxmetal
I was wondering how you recall a method for a case/switch statement. Here's the code I need filled in, thank you. The bold words are my methods.

Code:
		switch(CustomerType)
		{
			case 'r':
			case 'R': regularBill;

			System.exit(0);

				      break;

		    case 'p':
		    case 'P': premiumBill;

            System.exit(0);

		    		  break;

		    default: JOptionPane.showMessageDialog(null,"Invalid customer type.","Error",JOptionPane.PLAIN_MESSAGE);

		    System.exit(0);

	}

:confused:
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Coming from a language that doesn't require brackets on void method calls? :) As amdfanboy points out:
regularBill();
premiumBill();

Additional hint: change CustomerType from a char to an enumeration. So much more typesafe and easy to use ;)
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: kamper
Additional hint: change CustomerType from a char to an enumeration. So much more typesafe and easy to use ;)



:thumbsup:

I almost recommended that, but this seemed like HW so I didn't bother.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: amdfanboy
Originally posted by: kamper
Additional hint: change CustomerType from a char to an enumeration. So much more typesafe and easy to use ;)
:thumbsup:

I almost recommended that, but this seemed like HW so I didn't bother.
When you've got the chance to be evangelistic you've got to take it :) who knows, someday I might be maintaining his code
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: kamper
Originally posted by: amdfanboy
Originally posted by: kamper
Additional hint: change CustomerType from a char to an enumeration. So much more typesafe and easy to use ;)
:thumbsup:

I almost recommended that, but this seemed like HW so I didn't bother.
When you've got the chance to be evangelistic you've got to take it :) who knows, someday I might be maintaining his code

:Q