So this is my code:
for (Customer c : customers) {
if (custID == c.getCustID()) {
return c;
}
}
I am looking to be able to return some value if what is entered on the console does not match what is listed in the customers array
customers[]
This is from the source code which the user input if coming from:
int x = 0;
cout << "Please enter the customer ID!" << endl;
cin >> x;
Customer c = MyDataStore::getCustomer(x);
cout << c.print();
At this moment if the user enters a number which is listed in the array then it returns the correct value but I want a safe fall for when they enter an invalid number. Thank you!
Aucun commentaire:
Enregistrer un commentaire