Loading...
evgeni4 avatar evgeni4 12 Точки

08. Military Elite

Здравейте, на тая задача Тест №2  грешен, къде греша?може ли помощ малко

https://pastebin.com/eXV44YTr

83/100

https://judge.softuni.bg/Contests/Compete/Index/472#7

Create the following class hierarchy:

Soldier – general class for soldiers, holding id, first name and last name.

Private – lowest base soldier type, holding the field salary(double).

LeutenantGeneral – holds a set of Privates under his command.

SpecialisedSoldier – general class for all specialised soldiers – holds the corps of the soldier.

Engineer – holds a set of repairs. A repair holds a part name and hours worked(int).

Commando – holds a set of missions. A mission holds code name and a state (inProgress or Finished). A mission can be finished through the method CompleteMission().

Spy – holds the code number of the spy.

Extract interfaces for each class. (e.g. ISoldier, IPrivate, ILeutenantGeneral, etc. Each class should implement its respective interface. Validate the input where necessary (corps, mission state) - input should match exactly one of the required values, otherwise it should be treated as invalid. In case of an invalid mission state only the mission should be skipped.

You will receive from the console an unknown amount of lines containing information about soldiers until the command “End” is received. The information will be in one of the following formats:

Private: “Private <id> <firstName> <lastName> <salary>

LeutenantGeneral: “LeutenantGeneral <id> <firstName> <lastName> <salary> <private1Id> <private2Id> … <privateNId>” where privateXId will always be an Id of a private already received through the input.

Engineer: “Engineer <id> <firstName> <lastName> <salary> <corps> <repair1Part> <repair1Hours> … <repairNPart> <repairNHours>” where repairXPart is the name of a repaired part and repairXHours the hours it took to repair it (the two parameters will always come paired).

Commando: “Commando <id> <firstName> <lastName> <salary> <corps> <mission1CodeName>  <mission1state> … <missionNCodeName> <missionNstate>” a missions code name, description and state will always come together.

Spy: “Spy <id> <firstName> <lastName> <codeNumber>

Define magic method __toString() in all classes to print detailed information about the objects.

Private:
Name: <firstName> <lastName> Id: <id> Salary: <salary>

Spy:
Name: <firstName> <lastName> Id: <id>
Code Number: <codeNumber>

LeutenantGeneral:
Name: <firstName> <lastName> Id: <id> Salary: <salary>
Privates:
  <private1Id>
  <private2Id>
  …
  <privateNId>

Engineer:
Name: <firstName> <lastName> Id: <id> Salary: <salary>
Corps: <corps>
Repairs:
  <repair1X>
  <repair2X>
  …
  <repairNX>

Commando:
Name: <firstName> <lastName> Id: <id> Salary: <salary>
Corps: <corps>
Missions:
  <mission1X>
  <mission2X>
  …
  <missionNX>

Repair:
Part Name: <partName> Hours Worked: <hoursWorked>

Mission:
Code Name: <codeName> State: <state>

NOTE: Salary should be printed rounded to two decimal places after the separator.

Examples

Input

Output

Private 1 Pesho Peshev 22.22
Commando 13 Stamat Stamov 13.1 Airforces

Private 222 Toncho Tonchev 80.08

LeutenantGeneral 3 Joro Jorev 100 222 1

End

Name: Pesho Peshev Id: 1 Salary: 22.22

Name: Stamat Stamov Id: 13 Salary: 13.10

Corps: Airforces

Missions:

Name: Toncho Tonchev Id: 222 Salary: 80.08

Joro Jorev Id: 3 Salary: 100.00

Privates:

  Name: Toncho Tonchev Id: 222 Salary: 80.08

  Name: Pesho Peshev Id: 1 Salary: 22.22

Engineer 7 Pencho Penchev 12.23 Marines Boat 2 Crane 17

Commando 19 Penka Ivanova 150.15 Airforces HairyFoot finished Freedom inProgress

End

Name: Pencho Penchev Id: 7 Salary: 12.23

Corps: Marines

Repairs:

  Part Name: Boat Hours Worked: 2

  Part Name: Crane Hours Worked: 17

Name: Penka Ivanova Id: 19 Salary: 150.15

Corps: Airforces
Missions:

  Code Name: HairyFoot State: finished

  Code Name: Freedom State: inProgress

 

Тагове:
1
PHP Web Development Basics 21/06/2020 18:45:56
willystyle avatar willystyle 2472 Точки

Като добавяш войници в масива, просто ги пушвай, а не да ги добавяш по ключ, понеже при следващ войник от същия тип, го презаписваш.

https://pastebin.com/KbntJJ09

1
evgeni4 avatar evgeni4 12 Точки

благодаря

1
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.