Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
class GreenAlien class GreenAlien public String nam...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started