Advertisement
jaVer404

level13.lesson11.home02

May 20th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. package com.javarush.test.level13.lesson11.home02;
  2.  
  3. /* Погода
  4. 1. В классе Today реализовать интерфейс Weather.
  5. 2. Подумай, как связан параметр String type с методом getWeatherType().
  6. 3. Интерфейсы Weather и WeatherType уже реализованы.
  7. */
  8.  
  9. public class Solution
  10. {
  11.     public static void main(String[] args)
  12.     {
  13.         System.out.println(new Today(WeatherType.CLOUDY));
  14.         System.out.println(new Today(WeatherType.FOGGY));
  15.         System.out.println(new Today(WeatherType.FROZEN));
  16.     }
  17.  
  18.     static class Today implements Weather
  19.     {
  20.         private String type;
  21.  
  22.         Today(String type)
  23.         {
  24.             this.type = type;
  25.         }
  26.  
  27.         @Override
  28.         public String toString()
  29.         {
  30.             return String.format("%s for today", this.getWeatherType());
  31.         }
  32.         public String getWeatherType(){
  33.             return this.type;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement