Last active
October 12, 2017 18:00
-
-
Save Rahandi/3f2ccb6fc21cefa5e58abe7286950382 to your computer and use it in GitHub Desktop.
Circle
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 Circle { | |
private double radius; | |
private String color; | |
public Circle(){ | |
radius = 1.0; | |
color = "merah"; | |
} | |
public Circle(double r){ | |
radius = r; | |
color = "merah"; | |
} | |
public Circle(double r, String c){ | |
radius = r; | |
color = c; | |
} | |
void printing(){ | |
System.out.println("radius = " + radius); | |
System.out.println("color = " + color); | |
} | |
} |
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 Tester { | |
public static void main(String[] args){ | |
Circle polos = new Circle(); | |
Circle radius = new Circle(0.5); | |
Circle lengkap = new Circle(1.5, "biru"); | |
polos.printing(); | |
radius.printing(); | |
lengkap.printing(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment