Created
October 30, 2017 18:11
-
-
Save PocasPedro/ad1dfa671260340a8aab0014c1e00e87 to your computer and use it in GitHub Desktop.
Java Fundamentals for Kids - Exercise 22
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 HumanBeing { | |
public static class Head { | |
//Constructor | |
public Head(){ | |
System.out.println("Creating a Head object"); | |
} | |
public void move(){ | |
System.out.println("Moving"); | |
} | |
} | |
public static class Body { | |
//Constructor | |
public Body(){ | |
System.out.println("I have amazing abs!"); | |
} | |
public void exercising(){ | |
System.out.println("I am exercising"); | |
} | |
} | |
public static class Arm { | |
String armside; | |
//Constructor | |
public Arm(String side){ | |
armside = side; | |
System.out.println("I am the " + armside + " arm!"); | |
} | |
public void exercising(){ | |
System.out.println("Doing push ups!"); | |
} | |
} | |
public static class Leg { | |
String legside; | |
//Constructor | |
public Leg(String side){ | |
legside = side; | |
System.out.println("I am the " + legside + " arm!"); | |
} | |
public void exercising(){ | |
System.out.println("Doing skipping!"); | |
} | |
} | |
public static void main(String[] args) { | |
System.out.println("Using Multiple class in the same example"); | |
final Head head = new Head(); | |
final Body body = new Body(); | |
final Arm rightarm = new Arm("Right"); | |
final Arm leftarm = new Arm("Left"); | |
final Leg rightleg = new Leg("Right"); | |
final Leg leftleg = new Leg("Left"); | |
head.move(); | |
body.exercising(); | |
rightarm.exercising(); | |
leftarm.exercising(); | |
rightleg.exercising(); | |
leftleg.exercising(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment