0% found this document useful (0 votes)
153 views1 page

Colorwheel

This document contains the code for a ColorWheel class in Java. The class contains a string array of hex color codes and a getColor method that randomly selects and returns a color from the array as an integer. The getColor method creates a Random object to generate a random index between 0 and the length of the mColors array to select a random color string, which is then parsed into an integer and returned.

Uploaded by

api-355553261
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views1 page

Colorwheel

This document contains the code for a ColorWheel class in Java. The class contains a string array of hex color codes and a getColor method that randomly selects and returns a color from the array as an integer. The getColor method creates a Random object to generate a random index between 0 and the length of the mColors array to select a random color string, which is then parsed into an integer and returned.

Uploaded by

api-355553261
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

/Users/Al//////app/src///com///csumbfunfacts/ColorWheel.

java Page 1/1


Saved: 10/19/16, 9:00:17 AM Printed for: Alan Ayoub

1 package com.example.alanayoub.csumbfunfacts;
2
3 import android.graphics.Color;
4
5 import java.util.Random;
6
7 public class ColorWheel {
8 // fields (Member variables) - Properties about the object
9 public String[] mColors = {
10 "#39add1", // light blue
11 "#3079ab", // dark blue
12 "#c25975", // mauve
13 "#e15258", // red
14 "#f9845b", // orange
15 "#838cc7", // lavender
16 "#7d669e", // purple
17 "#53bbb4", // aqua
18 "#51b46d", // green
19 "#e0ab18", // mustard
20 "#637a91", // dark gray
21 "#f092b0", // pink
22 "#b7c0c7" // light gray
23 };
24
25 // Methods - Actions the object can take
26 public int getColor() {
27 String color;
28 // Randomly select a fact
29 Random randomGenerator = new Random();
30 int randomNumber = randomGenerator.nextInt(mColors.length);
31 color = mColors[randomNumber];
32 int colorAsInt = Color.parseColor(color);
33
34 return colorAsInt;
35 }
36 }
37

You might also like