"अपने कौशल को उन्नत करने के लिए बधाई। हमें ऐसे लोगों की आवश्यकता है जो कुछ भी करने के लिए तैयार हों।"
"मुझे यकीन है कि आपके पास अभी भी कई अधूरे काम हैं। उनमें से कुछ को पूरा करने का समय आ गया है!"
16
टास्क
Java Collections, स्तर 5, सबक 15
लॉक
Factories (part 1)
Hi!
Now you're going to dig into the Factory Method pattern. Let's take people as an example.
We'll determine what type of person someone is depending on his or her age.
In this task, we'll prepare the data that we'll use in the factory.
1. Create a shared Human interface for all types of people.
16
टास्क
Java Collections, स्तर 5, सबक 15
लॉक
Factories (part 2)
1. Create a public MaleFactory class in the male package with a public getPerson method that accepts one int age argument and
returns an appropriate object of a class implementing the Human interface.
8
टास्क
Java Collections, स्तर 5, सबक 15
लॉक
Factories (part 3)
1. Create a female package and create KidGirl, TeenGirl, and Woman classes in it by analogy with the classes in the male package.
2. Create a FemaleFactory in the female package by analogy with MaleFactory and using the same principle for getting objects.
8
टास्क
Java Collections, स्तर 5, सबक 15
लॉक
Factories (part 4)
1. At the root of the task, create an AbstractFactory interface and move the factories' common method into it.
2. Implement the AbstractFactory interface in both factories.