QuestionQuestion

Transcribed TextTranscribed Text

Color in Java using IntelliJ ANSI colors Any text-based application will use ANSI colors as follows: “\u001B[30m” Black “\u001B[31m” Red “\u001B[32m” Green “\u001B[33m” Yellow “\u001B[34m” Blue “\u001B[35m” Purple “\u001B[36m” Cyan “\u001B[37m” White The statements: System.out.println ("\u001B[34m" + "CS"); System.out.println ("\u001B[35m" + "IS"); System.out.println ("\u001B[32m" + "FUN"); produces the output: An ANSI color is to associate the color name (e.g. Black) and the ANSI string color (e.g. “\u001B”). ARGB colors Any of our Android applications will use ARGB colors as follows: “0xff000000” Black “0xffff0000” Red “0xff00ff00” Green “0xffffff00” Yellow “0xff0000ff” Blue “0xff800080” Purple “0xff00ffff” Cyan “0xffffffff” White An ARGB color is to associate the color name (e.g. Black) and the ARGB string color (e.g. “0xff000000”). The key thing here is that you need to take the string color “0xff000000” and turn it into an int 0xff000000. This might not be as easy as you think. You are to provide proper behavior for a ColorARGB object. An example of how the ARGB value will be used in Android is: int aColor = 0xff0000ff; // alpha(ff) fully opaque, red(00), green(00), blue (ff) ... anEditWidget.setBackgroundColor (aColor); // this method takes an int as an ARGB value You are to create a Java project PUNetIDColor that creates a text-based application that helps a young gradeschooler learn some basic colors. The application runs the user through all of the ANSI colors keeping score as the application is run. At the end, if the user gets all colors correct, print “Great Job”; otherwise, print “Keep Trying” Here is a sample output using a seed of 0 to seed a Random object such as mRandomGenerator = new Random (seed); The method nextInt gets a pseudo-random number between [0, value) where value is the argument to nextInt. Figure 1: LearnYourColors Design You are to design the entire LearnYourColors text-based application using UMLet. Your design is to be named PUNetIDLearnYourColors.uxf. The text-based application does not use any of the ARGB information I described; however, your design is to include ARGB behavior for the Android application. The main difference between ANSI and ARGB colors is that ANSI colors will only use <name, value> pairs as Java Strings. ARGB colors will also have <name, value> pairs as Java Strings but will have additional behavior to be able to return the String value as an int. All I/O is to happen in the method main. None of the other classes are to have any I/O. On the due date, print and turn in a one-page copy of your design identifiable to you. Also, drop the specified file into the CS260-01Drop folder on grace. LearnYourColors Text Implementation This is the Java text-based implementation of your design to run the application as shown in Figure 1 above. As you are implementing your Color class, I want you to write a ColorTest JUnit3 test class. You do not have to write any other test classes although you are advised to do so. In a perfect world with unlimited time, each class would have a test class, but we are on limited time, so I just want to make sure you know how to do this. On the due date, print and turn in each class starting with the class containing main. Print a superclass before any class that inherits from said superclass. Also, drop the entire project into the CS260-01Drop folder on grace. LearnYourColors Android Implementation The Android implementation will work similarly to the text-based version; however, the application is graphical using the Android API. Here are the screen shots your application will produce: Goals for Assignment #1: 1. Write a Java application using multiple classes 2. Understand the concept of packages to better organize classes 3. Use good OOP techniques in implementing your solution 4. Use the Java API which has a rich library of routines (e.g. Vector, Stack) 5. Use JUnit framework for testing classes 6. Use the IntelliJ IDEA for project development and testing 7. Write an Android application reusing some classes from the text-based version 8. Use Android Studio 3.0.1 for project development and testing

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class PUNetIDColor {

    // Method to play game
    public static void playGame() {

       // Construct Scanner for console input
       Scanner s = new Scanner(System.in);
       // int to store score
       int score = 0;
       // Construct ColorGenerator object
       ColorGenerator generator = new ColorGenerator(0);

       System.out.println("Learn Your Colors" + "\n");

       // Play 8 rounds of color guessing
       for (int round = 1; round <= 8; round++) {
            Color c = generator.getColor();
            // Query color guess from user
            System.out.print(c.getANSI() + "Color? ");
            String guess = s.nextLine();
            // Update score
            if (guess.equals(c.getName())) {
                score += 1;
            }
            // Print score
            System.out.println("Score: " + score + " / " + round + "\n");
       }

       // If the score is 8, notify the user "Great Job"
       if (score == 8)
            System.out.println("Great Job");
       // Else, at least one guess was incorrect; notify the user "Keep Trying"
       else
            System.out.println("Keep Trying");
    }


    public static void main(String[] args) {
       playGame();
    }
}...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$60.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats