Skip to content

Instantly share code, notes, and snippets.

@ProZhar
Created December 6, 2015 10:46
Show Gist options
  • Select an option

  • Save ProZhar/9613c93ce8ad32c56f2c to your computer and use it in GitHub Desktop.

Select an option

Save ProZhar/9613c93ce8ad32c56f2c to your computer and use it in GitHub Desktop.
com.javarush.test.level09.lesson11.home06
package com.javarush.test.level09.lesson11.home06;
import java.util.ArrayList;
/* Сказка «Красная Шапочка»
1. Есть пять классов: красная шапочка, бабушка, пирожок, дровосек, волк.
2. У каждого класса есть 2 поля: убил (killed ArrayList) и съел (ate ArrayList).
3. Необходимые объекты созданы (hood, grandmother, ...).
4. Расставь правильно связи, кто кого съел и убил, чтобы получилась логика сказки «Красная Шапочка».
PS: пирожки никто не ел. Их только несли. Волк чуток поел. А его потом убили.
*/
public class Solution {
public static LittleRedRidingHood hood = new LittleRedRidingHood();
public static Grandmother grandmother = new Grandmother();
public static Patty patty = new Patty();
public static Woodman woodman = new Woodman();
public static Wolf wolf = new Wolf();
public static void main(String[] args) {
// напишите тут ваш код
wolf.ate.add(grandmother);
wolf.ate.add(hood);
woodman.killed.add(wolf);
}
//красная шапочка
public static class LittleRedRidingHood extends StoryItem {
}
//бабушка
public static class Grandmother extends StoryItem {
}
//пирожок
public static class Patty extends StoryItem {
}
//дровосек
public static class Woodman extends StoryItem {
}
//волк
public static class Wolf extends StoryItem {
}
public static abstract class StoryItem {
public ArrayList<StoryItem> killed = new ArrayList<>();
public ArrayList<StoryItem> ate = new ArrayList<>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment