Advertisement
Azazavr

com.javarush.test.level03.lesson06.task03

Jan 30th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. package com.javarush.test.level03.lesson06.task03;
  2.  
  3. /* Семь цветов радуги
  4. Создать 7 объектов, чтобы на экран вывелись 7 цветов радуги (ROYGBIV).
  5. Каждый объект при создании выводит на экран определенный цвет.
  6. */
  7.  
  8. //Возможно, я решил ее немного не тем способом, которым должен был...
  9.  
  10. public class Solution
  11. {
  12.     public static void main(String[] args)
  13.     {
  14.         Red red = new Red();
  15.         red.toString();
  16.  
  17.         Orange orange = new Orange();
  18.         orange.toString();
  19.  
  20.         Yellow yellow = new Yellow();
  21.         yellow.toString();
  22.  
  23.         Green green = new Green();
  24.         green.toString();
  25.  
  26.         Blue blue = new Blue();
  27.         blue.toString();
  28.  
  29.         Indigo indigo = new Indigo();
  30.         indigo.toString();
  31.  
  32.         Violet violet = new Violet();
  33.         violet.toString();
  34.     }
  35.  
  36.     public static class Red
  37.     {
  38.         public Red() {
  39.             System.out.println("Red");
  40.         }
  41.     }
  42.  
  43.     public static class Orange
  44.     {
  45.         public Orange() {
  46.             System.out.println("Orange");
  47.         }
  48.     }
  49.  
  50.     public static class Yellow
  51.     {
  52.         public Yellow() {
  53.             System.out.println("Yellow");
  54.         }
  55.     }
  56.  
  57.     public static class Green
  58.     {
  59.         public Green() {
  60.             System.out.println("Green");
  61.         }
  62.     }
  63.  
  64.     public static class Blue
  65.     {
  66.         public Blue() {
  67.             System.out.println("Blue");
  68.         }
  69.     }
  70.  
  71.     public static class Indigo
  72.     {
  73.         public Indigo() {
  74.             System.out.println("Indigo");
  75.         }
  76.     }
  77.  
  78.     public static class Violet
  79.     {
  80.         public Violet() {
  81.             System.out.println("Violet");
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement