This is part of a program for a dog kennel where you can do the commands Register a new dog, Increase age, List dogs, Remove dog, Register new user, List users, Start auction, Make bid, etc. It's part of a school project, we've gotten pretty far but now we're stuck.
I want the user to be able to "start auction". In order to start an auction the dog must be registered (this part of the code is already done and works).
If the dog is already up for auction, I want the error "this dog is already up for auction".
If the dog already has an owner, I want the error to read "this dog already has an owner".
If the dog isn't registered to begin with, the error should read "dog does not exist in register".
I want to use the already created arraylists dogArrayList, auctionArraylist and userArrayList ("user" in userArrayList = owner of the dog).
One problem is that I have no idea where to put/how to use the userArrayList, or how to make this whole thing work in general.
I'd appreciate help as soon as possible, as the deadline is pretty soon.
private void startAuction() {
System.out.println("Enter name of dog: ");
String auctionDogName = spaceRemoval();
if (dogArrayList.contains(auctionDogName) && auctionArrayList.contains(auctionDogName)) {
System.out.println("Error: this dog is already up for auction" );
if (dogArrayList.contains(auctionDogName) && !auctionArrayList.contains(auctionDogName)) {
Auction a = new Auction(auctionDogName);
auctionArrayList.add(a);
System.out.println(auctionDogName
+ " has been put up for auction in auction #"
+ a.getAuctionNumber());
return;
} else {
System.out.println("Error: dog does not exist in register");
}
}
}
Aucun commentaire:
Enregistrer un commentaire