• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Random to the colour object

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[strike]Hello,

I Have three colours which have been initialised using the getters and setters ( for example brown, blue and black). I have also generated values 0,1 and 2 by using Random. I just need to know how do I point 0 to the colour brown, 1 to the colour blue and 2 to the colour black in a public method called change. So randomly the cream object changes to those colour.

Thanks in advance.

This is what I got so far...

[/code][/strike]
 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several control structures in java and all of them can be used to solve this problem. You should write out what you need to do in psuedocode to determine which structure is best for you. I have posted a link to a control structure tutorial.

An example of pseudocode:

Student class

create student object
initialize name, gpa, and major of student
print students information



Control structure tutorial: http://java-programming.suite101.com/article.cfm/introduction_to_java_control_structures
-Hunter
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic