So what will be the output of that code if I do sys.out.println(str) if the string is KD?
I have the code below and the corresponding output.
void openTopCards(){
LinkedList<String> fliper = new LinkedList <String>();
face.add("Up");
face.add("Dn");
for (int i=0; i < m; i++){
if (maneuver[i].size() != 0){
fliper.add(maneuver[i].pollLast());
fliper.add(face.peekFirst());
maneuver[i].addAll(fliper);
}
fliper.clear();
System.out.println("maneuver[" + i + "]" + maneuver[i]);
}
}
The output is:
maneuver[0][AD, Up]
maneuver[1][KD, 7D, Up]
maneuver[2][QD, 6D, AH, Up]
maneuver[3][JD, 5D, KH, 9H, Up]
maneuver[4][10D, 4D, QH, 8H, 5H, Up]
maneuver[5][9D, 3D, JH, 7H, 4H, 2H, Up]
maneuver[6][8D, 2D, 10H, 6H, 3H, AS, KS, Up]
I want the output to be like this:
maneuver[6][8D, 2D, 10H, 6H, 3H, AS, KSUp or Up KS] because there will other cards going on top of KS in the future.
I am thinking of putting all the open cards in another linkedlist then adding them all to the maneuver linkedlist.