Created
March 19, 2017 12:41
-
-
Save fermopili/90f99160808ebf9421be061519c06895 to your computer and use it in GitHub Desktop.
com.javarush.task.task14.task1415
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Клининговый центр | |
*/ | |
public class Solution { | |
public static void main(String[] args) { | |
List<Apartment> apartments = new ArrayList<Apartment>(); | |
apartments.add(new Apt1Room()); | |
apartments.add(new Apt2Room()); | |
apartments.add(new Apt3Room()); | |
cleanAllApartments(apartments); | |
} | |
public static void cleanAllApartments(List<Apartment> apartments) { | |
//написать тут вашу реализацию пунктов 1-4 | |
for(Apartment a:apartments) | |
{ | |
if(a instanceof Apt1Room) | |
((Apt1Room) a).clean1Room(); | |
if(a instanceof Apt2Room) | |
((Apt2Room) a).clean2Rooms(); | |
if(a instanceof Apt3Room) | |
((Apt3Room) a).clean3Rooms(); | |
} | |
} | |
static interface Apartment { | |
} | |
static class Apt1Room implements Apartment { | |
void clean1Room() { | |
System.out.println("1 room is cleaned"); | |
} | |
} | |
static class Apt2Room implements Apartment { | |
void clean2Rooms() { | |
System.out.println("2 rooms are cleaned"); | |
} | |
} | |
static class Apt3Room implements Apartment { | |
void clean3Rooms() { | |
System.out.println("3 rooms are cleaned"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment