Thread: Color objects
View Single Post
  #1 (permalink)  
Old 03-31-2008, 11:50 PM
CyberFrog CyberFrog is offline
Member
 
Join Date: Mar 2008
Posts: 8
CyberFrog is on a distinguished road
Color objects
hey all,
am a bit stuck here. basically would like to return the color object so am I right in thinking this is just the rgb values? If not then what would the return type be in the method? i.e. in this case I have put int for the rgb values

Also, what would be the syntax of returning the final three integers, seem to only be able to put one i.e. r in this case and not r,g,b?


Code:
package Chapter4; import java.awt.*; import java.util.Random; public class RandomColor { public int randomcolor(int r, int g, int b){ return r; } public static void main (String []args){ RandomColor pickcolor = new RandomColor(); Random generator = new Random(); int num1 = generator.nextInt(255); int num2 = generator.nextInt(255); int num3 = generator.nextInt(255); int randcolor = pickcolor.randomcolor(num1, num2, num3); System.out.println(randcolor); } }
Reply With Quote
Sponsored Links