Skip to content

Instantly share code, notes, and snippets.

@Maccimo
Last active April 7, 2017 21:17
Show Gist options
  • Save Maccimo/3fb56a8ea47eaa45a37e301b22de187a to your computer and use it in GitHub Desktop.
Save Maccimo/3fb56a8ea47eaa45a37e301b22de187a to your computer and use it in GitHub Desktop.
Sberbank JPoint 2017 Quiz
// 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