Add method listCard with int index parameter to print the card details of index
ID: 3594477 • Letter: A
Question
Add method listCard with int index parameter to print the card details of index in cards ArrayList in format “Card <index>: <card details>”:
if the indexValid(index), print card details of index (use .getDetails)
else print “Invalid index: <index>”
Add method listCard with int index parameter to print the card details of index in cards ArrayList in format “Card <index>: <card details>”:
if the indexValid(index), print card details of index (use .getDetails)
else print “Invalid index: <index>”
Explanation / Answer
public void listCard(int Index){ -->added method listCard
if(indexValid(index)){
System.out.println(cardsArrayList.get(index).getDetails()); --> Print card details if index valid
}
else {
System.out.println("Invalid Index: "+index); --> else print invalid index
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.