Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level03.lesson06.task03;
- /* Семь цветов радуги
- Создать 7 объектов, чтобы на экран вывелись 7 цветов радуги (ROYGBIV).
- Каждый объект при создании выводит на экран определенный цвет.
- */
- //Возможно, я решил ее немного не тем способом, которым должен был...
- public class Solution
- {
- public static void main(String[] args)
- {
- Red red = new Red();
- red.toString();
- Orange orange = new Orange();
- orange.toString();
- Yellow yellow = new Yellow();
- yellow.toString();
- Green green = new Green();
- green.toString();
- Blue blue = new Blue();
- blue.toString();
- Indigo indigo = new Indigo();
- indigo.toString();
- Violet violet = new Violet();
- violet.toString();
- }
- public static class Red
- {
- public Red() {
- System.out.println("Red");
- }
- }
- public static class Orange
- {
- public Orange() {
- System.out.println("Orange");
- }
- }
- public static class Yellow
- {
- public Yellow() {
- System.out.println("Yellow");
- }
- }
- public static class Green
- {
- public Green() {
- System.out.println("Green");
- }
- }
- public static class Blue
- {
- public Blue() {
- System.out.println("Blue");
- }
- }
- public static class Indigo
- {
- public Indigo() {
- System.out.println("Indigo");
- }
- }
- public static class Violet
- {
- public Violet() {
- System.out.println("Violet");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement