Advertisement
Azazavr

com.javarush.test.level05.lesson12.home03

Mar 25th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. package com.javarush.test.level05.lesson12.home03;
  2.  
  3. /* Создай классы Dog, Cat, Mouse
  4. Создай классы Dog, Cat, Mouse. Добавь по три поля в каждый класс, на твой выбор. Создай объекты для героев мультика Том и Джерри.
  5.  Так много, как только вспомнишь.
  6. Пример:
  7. Mouse jerryMouse = new Mouse(“Jerry”, 12 , 5), где 12 - высота в см, 5 - длина хвоста в см.
  8. */
  9.  
  10. public class Solution
  11. {
  12.     public static void main(String[] args)
  13.     {
  14.         Mouse jerryMouse = new Mouse("Jerry", 12 , 5);
  15.         Dog sparkyDog = new Dog("Sparky", 12, 10);
  16.         Cat tomCat = new Cat("Tom", 5, 32);
  17.  
  18.         //Напишите тут ваш код
  19.     }
  20.  
  21.     public static class Mouse
  22.     {
  23.         String name;
  24.         int height;
  25.         int tail;
  26.  
  27.         public Mouse(String name, int height, int tail)
  28.         {
  29.             this.name = name;
  30.             this.height = height;
  31.             this.tail = tail;
  32.         }
  33.     }
  34.  
  35.     public static class Dog
  36.     {
  37.         String name;
  38.         int strength;
  39.         int height;
  40.  
  41.         public Dog(String name, int strength, int height)
  42.         {
  43.             this.name = name;
  44.             this.strength = strength;
  45.             this.height = height;
  46.         }
  47.     }
  48.  
  49.     public static class Cat
  50.     {
  51.         String name;
  52.         int strength;
  53.         int speed;
  54.  
  55.         public Cat(String name, int strength, int speed)
  56.         {
  57.             this.name = name;
  58.             this.strength = strength;
  59.             this.speed = speed;
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement