L05

Due by the end of Tuesday, October 10

Starter Files:


SUBMIT / CHECK

Today's lab has five activities. The activities are designed for practicing method calling, modification, creation, along with understanding of parameters and arguments. You need to download the starter file "L05.java" and work within this file on this lab.

Today's Activities

Activity #1: Introduction
The starter file has a method printIntro. You need to: If you have completed the Activity 1 correctly, you should see the following output:
Activity 1: Welcome to the 'Pet Playtime' program by N. Neveditsin
where your name should be printed instead of N. Neveditsin
Activity #2: Feed Pets
The starter file has a method feedPet. You need to call the feedPet method from your main method three times: If you have completed the Activity 2 correctly, you should see the following output after the output for the Activity 1:
Activity 2: Feeding the cat some tuna! Feeding the dog some bones! Feeding the fish some flakes!
Activity #3: Dress Up Pets
Create a method dressPet under the Javadoc provided in the starter file. The method takes the pet's name and its outfit as parameters. In your main method, call the dressPet method with different outfits: If you have completed the Activity 3 correctly, you should see the following output after the output for the Activity 2:
Activity 3: Max looks funny in their pirate costume! Felix looks funny in their spider man costume!
Activity #4: Draw Cat's Face
Write a method called drawCatFace that accepts an integer parameter x, representing the position on the console screen where the cat's face should be drawn. Inside this method, you should generate spaces based on the X-coordinate, followed by the Unicode representation of a cat's face ("\uD83D\uDC31"). Hint: just use spaces as indentations, e.g., if x is 0, the cat's face has no spaces before it, if x is 5, the cat's face is placed after 5 spaces. Call the method two times If you have completed the Activity 4 correctly, you should see the following output after the output for the Activity 3:
Activity 4 🐱: 🐱 🐱
Sadly, some of you will not see the cat's face. You'll get a box or a question mark or something else like that. It's because your computer is missing that Unicode character. It won't be a problem for your submission -- we will be able to tell that a cat's face is supposed to be there.
Activity #5: Cat's 1D Laser Pointer Chase!
Scenario: You have a laser pointer. When you shine it on the "floor", the cat tries to catch it. This time, we are looking at the floor from a top view, and the laser dot can move from left (0) to right (10). The cat will try to pounce on the laser dot. The laser point is indented x spaces, where x is chosen randomly (see below). We will call x the X-coordinate of the laser dot. HINT: You can use the following code as an example to generate a pseudorandom number, x, from 0 (inclusive) to 10 (exclusive):
Random rand = new Random(); int x = rand.nextInt(10);

Submit this/these files:

You will be graded on the following:

  1. Modified the printIntro method correctly.
  2. Called the printIntro method from the main method.
  3. Called the feedPet method three times to feed the cat, dog, and fish.
  4. Created the dressPet method with the correct parameters.
  5. Called the dressPet method with the "pirate costume" outfit.
  6. Called the dressPet method with the "spider man costume" outfit.
  7. Created the drawCatFace method with the correct parameter and a proper Javadoc.
  8. Correctly generated spaces based on the X-coordinate within the drawCatFace method.
  9. Successfully added the Unicode representation of the cat's face in the drawCatFace method.
  10. Called the drawCatFace method properly as described in the Activity 4
  11. Created the playLaser method with the correct parameter and a proper Javadoc.
  12. Used a loop correctly within the playLaser method.
  13. Generated a random X-coordinate for the laser dot on each iteration.
  14. Called the playLaser method properly as described in the Activity 5 based on the user's input

SUBMIT   /   CHECK