Last active
April 7, 2017 21:17
-
-
Save Maccimo/3fb56a8ea47eaa45a37e301b22de187a to your computer and use it in GitHub Desktop.
Sberbank JPoint 2017 Quiz
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
// Source slightly modified. | |
class RGB { | |
final int r; | |
final int g; | |
final int b; | |
public RGB(int r, int g, int b) { | |
this.r = r; | |
this.g = g; | |
this.b = b; | |
} | |
public String toString() { | |
return String.format("#%02X%02X%02X", r, g, b); | |
} | |
} | |
class Color { | |
private final RGB rgb; | |
public Color() { | |
rgb = create(); | |
} | |
public RGB create() { | |
return new RGB(255, 255, 255); | |
} | |
public String toString() { | |
return rgb.toString(); | |
} | |
} | |
class Yellow extends Color { | |
private final int r = 255; | |
private int g = 255; | |
private int b = 0; | |
public RGB create() { | |
return new RGB(r, g, b); | |
} | |
} | |
public class Quiz { | |
public static void main(String... args) { | |
Color color = new Yellow(); | |
// What will be printed? | |
System.out.println(color); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment