YUHEE1984 / CatsOneday

1 stars 0 forks source link

03 - Our First Cat #3

Closed TheBeege closed 4 months ago

TheBeege commented 5 months ago

Goal

Sorry it took so long to get here, but it's time to create your first cat! Let's make it super cute.

Steps

What is a Cat?

  1. In the catsoneday package, make a new public class: Cat!
  2. Define a bunch of attributes for your cat. You probably want a String name, String sex, a String color, a String eyeColor, maybe a String furPattern, and an int weightInKg. Feel free to add more things we should know about cats.
  3. Define a public constructor method for your cat. Make sure the method takes in parameters for each of your cat's attributes. Then make sure to set the cat's attributes to those parameters.
  4. Define some public methods for actions a cat does. You probably want methods like purr, stretch, yawn, lounge, pounce, punch, and eat. Each of these methods should take no parameters and produce no outputs. Each one should print some text describing the cat's action.
  5. Define a toString method that takes no parameters and outputs a String. The string output should describe the attributes of your cat. It could be something like "This cat is " + this.name + ". " + this.name + " is a " + this.sex + " cat with " + this.color + " fur and " + this.eyeColor + " eyes.". Get creative with it!

Making Our First Cat

  1. Back in your App.java in the main method, create a new variable myCat of type Cat. Create a new instance of Cat, and set the parameters however you like.
  2. Using System.out.println, print out a description of myCat. (Remember step 5 from earlier?)
  3. After that, run of your cat's action methods.
  4. Run ./gradlew run to see your cat in action! Isn't it cute?

Congratulations on your first cat! Make sure to give it lots of cuddles.

YUHEE1984 commented 1 month ago

Reviewed it.