Question: Write a class called GreenAlien which has the following public attributes: an attribute called name of type String. This holds the Aliens name. an attribute
Write a class called GreenAlien which has the following public attributes:
- an attribute called name of type String. This holds the Aliens name.
- an attribute called eyeCount of type int. This holds the number of eyes an Alien has.
- an attribute called favouriteCandy of type String. This holds the Aliens perceived favourite candy.
And Methods:
- getDescription, which returns the String: "This Alien is called and has eyes. Gross. It seems to enjoy eating ".
When you test your Class, make sure to have multiple instances of GreenAliens in your main() method. It's good to get used to having multiple objects of your code.
Test GreenAlien gwerp = new GreenAlien(); gwerp.name = "Gwerp"; gwerp.eyeCount = 4; gwerp.favouriteCandy = "Marshmellows"; System.out.println(gwerp.getDescription()); Result This Alien is called Gwerp and has 4 eyes. Gross. It seems to enj
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
class GreenAlien class GreenAlien public String nam... View full answer
Get step-by-step solutions from verified subject matter experts
