Prices

  • 20
  • Locked
CrUD for a table inside a file. Read a file name for CrUD operations from the console. The program is started with the following arguments: -c productName price quantity Argument values: where id is 8 characters. productName is 30 characters. price is 8 characters. quantity is 4 characters. -c adds
You can't complete this task, because you're not signed in.
Comments (14)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Florin1
Level 31 , Romania
2 August, 16:26
I feel that this exercise could do with some inputs and outputs to clarify some confusion. Hope it helps. input arguments -c "Snowboard jacket with reflection" 123456789 12345 -c "Snowboard jacket with reflection" 123456789 12345 -c "Snowboard jacket with reflection" 123456789 12345 -c "Snowboard jacket with reflection" 123456789 12345 -c "Snowboard jacket with reflection" 123456789 12345 -c "Snowboard jacket with reflection" 123456789 12345 -c "Snowboard jacket" 12345 1 output (with altered ids, manually & directly in file, so as to test incrementing indexes) 1#######Snowboard jacket with reflecti123456781234 12345678Snowboard jacket with reflecti123456781234 12345671Snowboard jacket with reflecti123456781234 12345673Snowboard jacket with reflecti123456781234 12345679Snowboard jacket with reflecti123456781234 12345678Snowboard jacket with reflecti123456781234 123456##Snowboard jacket##########12345###1### // added # instead of space because of commenting format on this site // notice that there shouldn't be a new line here // notice that you shouldn't expect that the last index is the greatest (maybe, not necessary?) // notice trimmed data from input to output, based on mentioned limits
LuisRC
Level 39 , Gijón, Spain
29 March, 20:08
What would happen with the given solution by CodeGym if the text file is empty? According to my test it will fail.
Jurij Thmsn
Level 29 , Flensburg, Germany
15 April 2021, 15:40
Wow, really tough exercise. Some of the requirements mislead me: In condition nr. 4: the quotation marks made me think that "-c productName price quantity" is the entered program argument, but it is entered without the quotation marks (big difference - array with 4 slots instead of one slot) For me, it wasn't clear if i should write the code for one set of arguments or multiple sets. (It's just for one!) And you have to check for args length to validate, even if other if - statements logically include this requirement. Still a really nice, challenging exercise. I'd love to know how other people solved this task.
MoJo
Level 22 , Cairns, Australia
17 December 2020, 12:00
The example output is confusing... Is 198479 the ID that follows 19847?
Roman
Level 41
18 December 2020, 07:23
An example for seeing the structure of a file. Imagine that lines with id from 19848 to 198478 were deleted from the file.
aem
Level 22 , Amsterdam, Netherlands
21 October 2020, 10:47
For requirement 4 I'm getting the following recommendation message from the mentor: CodeGym security exception. You are performing a forbidden or potentially dangerous operation. When I run the task on IntelliJ the end result is as expected. Where does this security exception happens?
Roman
Level 41
23 October 2020, 06:00
Please post your question with the attached solution in the section Help.
Sven
Level 19 , Hanover, Germany
8 October 2019, 14:23
I don't have a clue why this isn't passing the test. It seems to work flawlessly with a test file. Please help me out here.
Roman
Level 41
9 October 2019, 06:23
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
lordheraldor
Level 23 , Newark, United States
16 March 2019, 15:28
I have a question regarding this task and possibly the other Prices task and it is: In the args, are the values string values that contains 30 characters for productName, 8 in price, which includes the period, and 4 for quantity; and that if the string are not the mentioned lengths they have been padded out with spaces to fill the character length. And we have to add in the values without such spacing into the file. Am I correct?
Roman
Level 41
18 March 2019, 08:49
in the args:
-c "Swim trunks, blue" 159.00 12
in the file:
19846   Swim trunks, blue             159.00  12  |
19846 - just an example | - to indicate the border
lordheraldor
Level 23 , Newark, United States
21 March 2019, 13:58
Cool, thanks for the clarification.
23 February 2021, 21:25
Where does 19846 come from? From the file or from the args? Or are we on another level of abstraction here?
Roman
Level 41
4 March 2021, 15:44
19846 - just an example of id From the task condition: -c adds the product with the specified parameters to the end of the file, and generates an id by incrementing the maximum id found in the file.