Batch CrUD: multiple Creations, Updates, Deletions. The program runs with one of the following sets of arguments: -c name1 sex1 bd1 name2 sex2 bd2 ... -u id1 name1 sex1 bd1 id2 name2 sex2 bd2 ... -d id1 id2 id3 id4 ... -i id1 id2 id3 id4 ... Argument values: name (String) sex ("m" or "f") bd (birth
You must be signed in to leave a comment
9 February 2022, 19:24
For the conditions -d and -i i use a for(int i = 1; i < args.lenght-1; i++) and the task didn't pass. I changed in i < args.lenght; only like that... and pass, but i don't understand why? If args.lenght = 10 and args = "-d", from 1 to 9 I have the rest of args array. If i loop until i = 10 I am not out of array!?
15 February 2022, 22:59
If you add "i <args.length-1" you are actually not reaching the last item of the array because the " < " will not make the i variable take the number of the last item, so in the example you gave, the i variable will stop at "8" and not at "9" . You would need to use either " i<args.length" or " i<=args.length-1"
17 February 2022, 18:16
Yes, i remember that i was very tired when i ask this question. Is crystal clear that i<args.length is i less than length, but then... 😅😅😅 Tk you! 😉
23 September 2021, 18:45
Why would the code for this and previous task have separate CreateMale and CreateFemale methods, instead of just having a single CreatePerson method that passes the Sex as a parameter? Seems like it would be less code that way.
12 August 2021, 12:57
i wrote my solution, test it once, twice, 15 times, everything worked great. "check solution" and.. no is no good, i pressed "get correct solution", check each method, one by one, all of my methods had the same idea as the "correct" ones, i actually liked mine more (were shorter, cleaner and easier to read), still got error like: "Be sure the args.lenght doesn't change when '-d' is passed " (i checked, it was fine) "Be sure the information are displayed as required when '-i' is passed are as required" (i checked, on my solution were identical with the one in the "correct" one) and 2 more errors that i can't remember and can't see them anymore because "the task was solved already". final was to solve this: copy paste to the "correct" one and move on. because that's what codding is about: providing the code some boss want line by line and not your own solution!
6 June 2021, 10:37
task1711 (CRUD 2) CAVEATS: Validation of requirement 7 is broken. To get past the validator you need to have something like this:You will get failed if you instead have something like this: Requirement 8 is fully in the unmentionable category but it indirectly gives a valuable hint with regard to consistency level that the code has to achieve. I.e. if there is a synchronisation block in every case label of a switch that switches on commands then this implies that the whole argument list of a command should be processed atomically. To get past the validator you need stick a synchronized block in every case branch of the switch statement, regardless of how you actually handle synchronisation in your code. Don't forget the default branch, if you have any. Empty blocks are perfectly fine.
23 September 2021, 19:11
Some of these tasks assume the input will be correctly formatted. This task and the one before it don't ask the programmer to do any preparation at all for the input being in the wrong order or formatted wrong or with typos, or in the case of your comment, no input given at all. Realistically there should be proper error handling for that kind of thing here, but my guess is that it would make the task too long.
Ian De Bie Full Stack Developer
16 October 2020, 17:32
be careful if you have a default branch on your switch statement as it expects EVERYTHING to have a synchronization block, so maybe easier to just not have a default. Took me many attempts to finally understand why failing the last validation, even though my default was only throwing an illegal argument exception and had nothing to do with the other cases checking the arguments..
18 May 2020, 15:27
PRO TIP!!! This task uses the String args bit of the main(String args) If you want to test this and run code based on th String args in IntelliJ do this: 1. Click on the play button next to public static void main.... 2. Select the last option 'Create solution main'... 3. In the Create Run Configuration window look to Program Arguments 4. Set your arguements here for example: -u 0 Washington m "04 15 1990" 1 Smith f "03 19 1987" or -c 0 Washington m "04 15 1990" 1 Smith f "03 19 1987" This took me a LONG time to figure out, hope it helps someone else.
18 July 2019, 06:39
is there a way how to push arguments via codegym compiler?
19 July 2019, 06:38
Use IDEA or another IDE
1 December 2019, 15:10
hi, the instructions for this taks should be updated with at least 1 input example please. It looks like the date is put with quotes when the command runs, and it is quite difficult to figure it out.why the codes is not working if you don't know the input. Thanks
2 December 2019, 07:59
Read how parameters are passed on the command line. If the parameter has spaces inside itself, then it must be in quotation marks.
31 May 2019, 07:05
Is it just me or the instruction for this task is so vague & unclear that you, too, have no idea what they actually expect us to do? ;)
Ewerton Backend Developer
3 July 2019, 15:45
You are going to do the same thing you did on CRUD, but with a indefinite amount of arguments, and they are forcing you to use switch/case and synchronized.