07. Google 80/100 (Defining Classes - Exercises)
Здравейте,
На 7 задача от Defining Classes - Exercises в Judge 4-тият тест не минава. Предполагам, че грешката е в листовете pokemons, parents и children, другия вариант е в toString() метода на класа Person. Ако някой открие грешката, моля да сподели :)
Класове:
Main -> https://pastebin.com/Hw3RxYnG
Person -> https://pastebin.com/ysLk0MuB
Company -> https://pastebin.com/Cz1hTV70
Car -> https://pastebin.com/DcnQPRTW
Pokemon -> https://pastebin.com/sJEtVESz
Parents -> https://pastebin.com/BxGpg5Af
Children -> https://pastebin.com/dgzmGwDZ
Линк към Judge: https://judge.softuni.org/Contests/Compete/Index/1518#6
Условие:
Google is always watching you, so it should come as no surprise that they know everything about you (even your pokemon collection), since you’re a really good at writing classes, Google asked you to design a Class that can hold all the information they need for people.
You will receive an unknown number of rows from the console until you receive the "End" command, on each of those lines there will be information about a person in one of the following formats:
- "{Name} company {companyName} {department} {salary}"
- "{Name} pokemon {pokemonName} {pokemonType}"
- "{Name} parents {parentName} {parentBirthday}"
- "{Name} children {childName} {childBirthday}"
- "{Name} car {carModel} {carSpeed}"
You should structure all information about a person in a class with nested subclasses. People names are unique - there won't be 2 people with the same name, a person can also have only 1 company and car, but can have multiple parents, children and pokemons. After the command "End" is received on the next line you will receive a single name, you should print all information about that person. Note that information can change during the input, for instance if we receive multiple lines which specify a person company, only the last one should be the one remembered. The salary must be formated to two decimal places after the seperator.
Note: print the information in format:
{personName}
Company:
{companyName} {companyDepartment} {salary}
...
Children:
{childName} {childBirthday}
{childName} {childBirthday}
Examples
Input |
Output |
PeterSmith company PeshInc Management 1000.00 JohnJohnson car Trabant 30 PeterSmith pokemon Pikachu Electricity PeterSmith parents PoshoPeshev 22/02/1920 JohnJohnson pokemon Electrode Electricity End JohnJohnson |
JohnJohnson Company: Car: Trabant 30 Pokemon: Electrode Electricity Parents: Children: |
GeorgeJohnson pokemon Onyx Rock GeorgeJohnson parents SaraJohnson 13/03/1933 AlexAlexson pokemon Moltres Fire GeorgeJohnson company JeleInc Jelior 777.77 GeorgeJohnson children SamJohnson 01/01/2001 SmithSmithon pokemon Blastoise Water GeorgeJohnson car AudiA4 180 GeorgeJohnson pokemon Charizard Fire End GeorgeJohnson |
GeorgeJohnson Company: JeleInc Jelior 777.77 Car: AudiA4 180 Pokemon: Onyx Rock Charizard Fire Parents: SaraJohnson 13/03/1933 Children: SamJohnson 01/01/2001 |
Благодаря! Не бях забелязал условието за Salary и main-a изглежда по-добре