Професионална програма
Loading...
Dimov79 avatar Dimov79 7 Точки

Ex. 6 SoftUni Parking from Maps, Lambda and Stream ex.

Здравейте, 

искам да помоля за малко помощ. Получавам резултат за всеки вход от трите входа на задатачат, както е в примера, но при в judge получавам run time error 

https://pastebin.com/jrj1T6Ty

 

https://judge.softuni.bg/Contests/Compete/Index/1312#4

 

6.SoftUni Parking

SoftUni just got a new parking lot. It's so fancy, it even has online parking validation. Except, the online service doesn't work. It can only receive users' data, but doesn't know what to do with it. Good thing you're on the dev team and know how to fix it, right?

Write a program, which validates parking for an online service. Users can register to park and unregister to leave.

The program receives 2 commands:

  • "register {username} {licensePlateNumber}":

    • The system only supports one car per user at the moment, so if a user tries to register another license plate, using the same username, the system should print:
      "ERROR: already registered with plate number {licensePlateNumber}"

    • If the aforementioned checks pass successfully, the plate can be registered, so the
      system should print:
      "{username} registered {licensePlateNumber} successfully"

  • "unregister {username}":

    • If the user is not present in the database, the system should print:
      "ERROR: user {username} not found"

    • If the aforementioned check passes successfully, the system should print:
      "{username} unregistered successfully"

After you execute all of the commands, print all the currently registered users and their license plates in the format:

  • "{username} => {licensePlateNumber}"

Input

  • First line: n - number of commands - integer

  • Next n lines: commands in one of two possible formats:

    • Register: "register {username} {licensePlateNumber}"

    • Unregister: "unregister {username}"

The input will always be valid and you do not need to check it explicitly.

Examples

Input

Output

5

register John CS1234JS

register George JAVA123S

register Andy AB4142CD

register Jesica VR1223EE

unregister Andy

John registered CS1234JS successfully

George registered JAVA123S successfully

Andy registered AB4142CD successfully

Jesica registered VR1223EE successfully

Andy unregistered successfully

John => CS1234JS

George => JAVA123S

Jesica => VR1223EE

 

 

4

register Jony AA4132BB

register Jony AA4132BB

register Linda AA9999BB

unregister Jony

Jony registered AA4132BB successfully

ERROR: already registered with plate number AA4132BB

Linda registered AA9999BB successfully

Jony unregistered successfully

Linda => AA9999BB

6

register Jacob MM1111XX

register Anthony AB1111XX

unregister Jacob

register Joshua DD1111XX

unregister Lily

register Samantha AA9999BB

 

 

Jacob registered MM1111XX successfully

Anthony registered AB1111XX successfully

Jacob unregistered successfully

Joshua registered DD1111XX successfully

ERROR: user Lily not found

Samantha registered AA9999BB successfully

Anthony => AB1111XX

Joshua => DD1111XX

Samantha => AA9999BB

Тагове:
0
Module: Java Advanced 11/11/2019 21:03:38
svephoto avatar svephoto 689 Точки

Здравей, колега,

 

Грешката ти беше в това, че прочиташ първия входящ масив веднъж преди да влезеш в цикъла и се оказва, че преди последната итерация трябва да прочетеш още един масив и програмата чака да прочете ред, който обаче няма да бъде въведен, защото целият брой масиви вече е изчерпан. Направих малката промяна, от която имаше нужда, а именно: да започнеш да четеш масивите вътре в цикъла и така дава 100/100 в Judge. Ето кода, мисля, че веднага ще видиш за какво става въпрос:

 

https://pastebin.com/VrwJyix5

 

Успех ти желая и занапред!

0
12/11/2019 08:30:55
Dimov79 avatar Dimov79 7 Точки

Благодаря много :)

0
svephoto avatar svephoto 689 Точки

Моля! :-)

0