jQuery in Action, 3rd edition
The moose likes Applets and the fly likes Switch or Else If Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Switch or Else If" Watch "Switch or Else If" New topic
Author

Switch or Else If

Imogen Handy
Greenhorn

Joined: May 03, 2013
Posts: 1
My project requires me to create a game which produces random and golden ratio rectangles when the user presses one button, i have attempted to use a swich statement here so when the user clicks the programme will either draw a rectangle or a golden ratio rectange but when the button is clicked it only draws the 1st case is there anyway to get it to alternate between cases? Or should i be using an if else statement or even something else

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32635
    
215

Imogen,
Welcome to CodeRanch! We used "code" instead of "highlight" here for blocks of code. I've edited your post to fix that so the code is easier to read.

I would use the if/else there since there are only two cases. It is a little clearer that way.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Switch or Else If
 
It's not a secret anymore!