This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Switch or Else If" Watch "Switch or Else If" New topic

Switch or Else If

Imogen Handy

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
internet detective

Joined: May 26, 2003
Posts: 30136

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.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Don't get me started about those stupid light bulbs.
subject: Switch or Else If
Similar Threads
Create Bar Chart
I don't know this syntax
Problem in code need help
Changing the color of a dot from blue to red or green with the use of buttons
Drawing with mouse