CodeGym /Courses /Java Collections /Big task: Creational design pattern

Big task: Creational design pattern

Java Collections
Level 5 , Lesson 15
Available

"Hello, soldier!"

"Congratulations on upgrading your skills. We need guys who are prepared to do anything."

"I'm sure you still have many unfinished tasks. It's time to finish some of them!"

16
Task
Java Collections, level 5, lesson 15
Locked
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
Task
Java Collections, level 5, lesson 15
Locked
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
Task
Java Collections, level 5, lesson 15
Locked
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
Task
Java Collections, level 5, lesson 15
Locked
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.
Comments (7)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Justin Smith Level 41, Greenfield, USA, United States
8 December 2022
It's pretty easy but a good learning project.
Ibrahim Level 41, Sheffield, United Kingdom
10 June 2022
Really enjoyed this big task as it allowed me to learn more about the factory design pattern and its different types.
30 August 2020
In previous examples I saw mostly factories with static methods. In these tasks we had to instantiate the factory class. Is it fine to use either?
fzw Level 41, West University Place, United States
6 May 2020
I am running out of dark matters...
Tom Level 41, San Jose, Sweden
23 May 2021
same!!
Andrei Level 41
20 July 2021
Bros, wth, you need to do more exercises! 😂 I have 1357 dark matter.
Justin Smith Level 41, Greenfield, USA, United States
5 December 2022
Same, I rely on these big end-of-chapter projects to reload, but the last few have been a bit skimpy on handing the stuff out.