RoulettePocket.java - The Roulette Wheel Colors class...

This preview shows page 1 - 2 out of 2 pages.

/** The Roulette Wheel Colors class represents a roulette wheel pocket. */ public class RoulettePocket { // Fields int number; // The pocket number String color; // The pocket color /** The class constructor accepts an integer value for the pocket number as an argument. @param n The pocket number. */ public RoulettePocket(int n) { // Set the number field. number = n; // For pockets 1 through 10, the odd-numbered pockets // are red and the even-numbered pockets are black. if (number >= 1 && number <= 10) { if (number % 2 == 0) { color = "Black"; // Even } else { color = "Red"; // Odd } } // For pockets 11 through 18, the odd-numbered pockets // are black and the even-numbered pockets are red. else if (number >= 11 && number <= 18) { if (number % 2 == 0) { color = "Red"; // Even } else { color = "Black";
Image of page 1

Subscribe to view the full document.

Image of page 2

Unformatted text preview: // Odd } } // For pockets 19 through 28, the odd-numbered pockets // are red and the even-numbered pockets are black. else if (number >= 19 && number <= 28) { if (number % 2 == 0) { color = "Black"; // Even } else { color = "Red"; // Odd } } // For pockets 29 through 36, the odd-numbered pockets // are black and the even-numbered pockets are red. else if (number >= 29 && number <= 36) { if (number % 2 == 0) { color = "Red"; // Even } else { color = "Black"; // Odd } } // Pocket 0 is green. else { color = "Green"; // Zero } } /** The getPocketColor method returns the pocket's color, as a string. @return The pocket color. */ public String getPocketColor() { // Return the value of the color field. return color; } }...
View Full Document

  • Fall '13
  • Primary color

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern