The goal of this project is to become more familiar with creating and using classes and objects in Java, to further introduce you to the concepts of abstraction and modularization, and to introduce you to collections of items. In this project you will build on your Project 3. You will add a new Text class that will enable you to show text.

Instructions

  • Create a new Java project named “Project4_netid” (where you replace netid with your NetID)
  • Create an AlphabetPanel class that extends JPanel (see Section 4.6), which uses the Text class

Add an AlphabetPanel class and implement the following:

  • Shows all of the letters of the alphabet (using a Text object for each letter)
  • reset – a method that resets the alphabet panel letters all to black
  • setLetterColor – a method that sets the color of a specified letter to a specified color
  • getLetterColor – a method that gets the color of a specified letter. If the letter is not valid (i.e., not in the panel), return null.
  • ERROR HANDLING: make sure the previous two methods work the same for upper and lower case letters; and that it correctly handles (ignores) characters that are not ‘A’ through ‘Z’
  • hasLetterBeenSeen – a method that returns true if the letter has been pressed (i.e., changed color) since the last reset
  • isVowel – returns whether or not the character is a vowel
  • Add a main method that creates an AlphabetPanel object and puts it in a JFrame, it should react to typed input in the following manner: when a consonant is pressed that letter should turn red, a vowel should change to green, the spacebar should reset or clear the alphabet panel (all other keys should do nothing)

Be sure to:

  • Use proper indentation
  • Use appropriate variable/field names
  • Group like things together (items that are part of the same objects)
  • Use appropriate comments – including comments for each method
  • Check your curly braces

Hints / tips

  • Internally, characters are stored as numbers, specifically, as integers. This means we can work with AlphabetPanel letters as if they were numbers. For example, ‘A’ + 1 = ‘B’. Similarly, to determine that ‘Y’ is the 25th letter of the alphabet, we could calculate ‘Y’-‘A’+1 = 25.
  • In order to support key events in the AlphabetPanel (or later in Project 6 in the HangmanGame class) you will need to add the following code (which you need to complete) in the constructor of your AlphabetPanel class:
this.setFocusable(true); // enables panel to listen to key events this.addKeyListener(new KeyAdapter(){ public void keyTyped(KeyEvent e) { // logic to handle key events });
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.