I'm quite new to programming and I want to be able to prevent a duplicate String input from the user. But so far the code below does not work (or is completely ignored by the program). Thanks in advance!!
boolean current = false;
for (int i = 0; i < dogs.size(); i++) {
System.out.println("Dog name: ");
String dogName = scan.nextLine().toLowerCase();
if (dogName.equals(dogs.get(i).getName())) {
auction.add(new auction(dogName));
System.out.printf(dogName + " has been put up for auction in auction #%d", i);
System.out.println();
current = true;
}//code below does not work
if (auction.contains(dogName)) {
System.out.println("Error: this dog is already up for auction.");
}
}
if (current == false) {
System.out.println("Error: no such dog in the register");
}