Chicken factory

  • 16
  • Locked
Let's create an international chicken factory. We'll fill it with chickens from all over the world. Create a list that indicates each hen's nationality and we'll track how many eggs they lay each month. How do you do that? Using abstract classes and inheritance, of course.
You can't complete this task, because you're not signed in.
Comments (11)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 15 , Old Town, United States
9 June, 14:45
took a while, but good learning. happy coding! :)
Michael T Schaefer
Level 15 , Columbia, United States
13 May, 01:00
Why is the getDescription() from the child class called when we use the HenFactory's getHen() to declare a new variable, "hen", of Hen type when it points to one of the child class's in memory? I checked this lesson and this website and it seems to say the opposite. Can someone clarify? To review/summarize my question... does the declaration type qualify the methods available to that object? Or is its location in memory (what comes after the 'new' keyword)? I hope I'm wording all of this accurately and clearly. Still feel like a noob! : )
Lucas Hoage
Level 14 , Savannah, United States
12 June 2020, 21:13
A little tough. Doable.
Level 15 , Colnbrook, United Kingdom
2 May 2020, 21:53
getDescription ()
output must be exactly this format: <parent class>.getDescription() + " I come from <continent>. I lay <n> eggs a month." My output was a String.format(<parent class>.getDescription() + " I come from <continent>. I lay <n> eggs a month."....). Was giving me the right output, but wasn't passing the testing.
Andreas Dengler
Level 16 , Bielefeld, Deutschland
28 April 2020, 15:49
Hei I have another strange Problem. We need to create the classes if the hens in new files (I work on my phone) and it happens all the time. I create the file and change the class to what it needs to be go to the nect file change things there and when I look at the already finished file every change is gone and i need to redo it and when I am finished the other file is empty again. I will never be able to pass the task this way... I just realised that the files doesnt get deleted randomly every time you create a new file the changes of the other files get deleted
dabay wang
Level 22 , New Ross, Ireland
5 April 2020, 22:31
Having an interface with only fields, like Continent, is not best practice. Maybe change to Enum instead.
Level 20 , Lagos, Nigeria
22 June 2019, 01:32
This is absolutely awesome.
Level 16 , India
1 October 2018, 06:18
Some points identified that needs fixing in this task: 1. Hen class getDescription method should return "I am a chicken." which is correct. However, during verification, condition number 6, gives an example and states "I'm a chicken." This is very confusing. Both statements should match to a T. 2. The same condition 6 also states that the message for North America should display: I'm a chicken. I come from North America. I lay 5 eggs a month. This was not verifying for me even though I ensured the message is exactly the same. It turns out, you have to use Continent.NorthAmerica instead of hardcoding "North America" in the return message. But, point to be noted: Continent.NorthAmerica returns "NorthAmerica" and not "North America" (with a space). Time is wasted in trying to match the program as per conditions, even though your code works perfectly fine. Please take a note of these minute issues which are like witch hunt and take a lot of time.
Level 29 , Seattle, United States
30 January 2019, 18:53
Another point, copied from the validation: The description of an AfricanHen should have the following format: <parent class>.getDescription() + "I come from Africa. I lay <n> eggs per month.", where <n> is the number of eggs per month (returned by the getMonthlyEggCount method. For example: I'm a chicken. I come from Africa. I lay 5 eggs a month. The "following format" section shows ...getDescription() + "I come from...". This would not produce a space between sentences. This would output: "I'm a chicken.I come from...", but the example printout shows "I'm a chicken. I come from..." with a space between sentences. Another one is "...eggs per month." vs "...eggs a month."
Level 41
31 January 2019, 07:13
Thanks, we will fix it soon.
Level 29 , Seattle, United States
31 January 2019, 16:49
Thanks! You are awesome :)