Animal set

  • 10
  • Locked
Let's add animals to sets. First, we'll create Cat and Dog classes and then createCats and createDogs methods, which will return sets with dogs and cats. We'll write a join method that returns the union of the dog and cat sets. To handle any unfriendliness, we'll create the removeCats method, which removes cats from pets. And finally — the printPets method, which displays everything in pets.
You can't complete this task, because you're not signed in.
Comments (9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Andrew Evans
Level 17 , San Jose, Canada
14 February 2022, 14:37
instanceof is your friend
Aleksa
Level 18 , Belgrade, Serbia
23 March 2022, 17:39
how?
proegg123
Level 16 , Slovakia
30 November 2021, 12:28
Hi, there seems to be an issue - package com.sun.xml.internal.ws.policy.privateutil does not exist. file com/codegym/task/task08/task0820/Solution.java, line 3, position 88
Justin Smith
Level 38 , Greenfield, USA, United States
14 July 2021, 18:43
I was able to run my solution correctly, but when validating it generated an error that it could not even compile the code. It pointed to line 3, which is an import statement that I didn't even write: import com.codegym.task.task06.task0607.Cat I commented out this line and it worked. Is this a bug or was finding this supposed to be part of the task? Anyone else encounter this problem?
Roman
Level 41
16 July 2021, 06:04
Most likely you copied the Cat class or something related to it from the task0607.
ImDevin
Level 15 , Old Town, United States
2 May 2021, 16:53
good exercise to see the big picture with different components (classes, methods, etc). 👍
Lucas Hoage
Level 14 , Savannah, United States
4 June 2020, 02:54
Very doable. Slightly hard. If you keep getting stuck on the add and remove parts, remember, it wants you to add the objects in the set. Not the set itself. How can you extract the contents? The type of data you want to extract into a new variable must be the same type! Remember how we used to print out sets and arrays? The answer is located on: https://codegym.cc/quests/lectures/questsyntax.level08.lecture02
Anonymous #10410173 Full Stack Developer
15 October 2019, 18:42
/* Comment has been deleted */
Roman
Level 41
16 October 2019, 05:57
Posting the solution in the comments is prohibited.