• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Switch or Else If

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

author & internet detective
Posts: 40035
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Always! Wait. Never. Shut up. Look at this tiny ad.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic