Here is the code that adds the machine manufacturer.
String empty = ""; String manufacturer; System.out.print("Please enter car's manufacturer: "); do { manufacturer = System.console().readLine(); if (Objects.equals(manufacturer, empty)) { System.out.print("You didn't enter car's manufacturer! Please enter again: "); } } while (Objects.equals(manufacturer, empty)); carStorage.newCar(manufacturer); System.out.print("\nYour manufacturer is added!"); But there is one such bug, if I put a space instead of an empty value, it will count it and the code will perform its action and put it into the carStorage. So I decided to create an array with my 'spaces'
String empty[] ={""," "," "," "," "," "," " и т.д.}
it does not compare with these values. How else is this business to implement it? So that the spaces allowed in the beginning are not readable, and even if the user entered 100 spaces, said that you did not enter a name?
trimoperation, the string is empty - do not enter anything into the array and ask the user to translate the data ..... that is, compare not with themanufacturer, but with themanufacturer.trim()- Alexey Shimansky