Created
October 30, 2017 17:48
-
-
Save PocasPedro/dbb81693cd94b9abd92aa184fca679d2 to your computer and use it in GitHub Desktop.
Java Fundamentals for Kids - Exercise 21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Head { | |
String eyecolor; | |
String nosetype; | |
boolean moustache; | |
Head (String eyes, String nose, boolean mouthhair){ | |
eyecolor = eyes; | |
nosetype = nose; | |
moustache = mouthhair; | |
} | |
public static void main(String[] args) { | |
Head newhead = new Head("Green","Round",false); | |
newhead.print(); | |
} | |
void print(){ | |
System.out.println("My head has " + eyecolor + " eyes and a " + nosetype + " nose!"); | |
if(moustache==true) | |
System.out.println("My head has a moustache!"); | |
else | |
System.out.println("My head has no moustache!"); | |
} | |
} |
public class Head {
String eyecolor;
String nosetype;
boolean moustache;
public Head (String eyes, String nose, boolean mouthhair){
eyecolor = eyes;
nosetype = nose;
moustache = mouthhair;
}
void print(){
System.out.println("My head has " + eyecolor + " eyes and a " + nosetype + " nose!");
if (moustache==true) {
System.out.println("My head has a moustache!");
} else {
System.out.println("My head has no moustache!");
}
}
//Main method
public static void main(String[] args) {
Head newhead = new Head("Green","Round",false);
newhead.print();
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minor change:
public class Head {
}