public class Briefcase{
private int amount;
private String face;
private boolean isOpen = false;
public Briefcase(int amount,int cNumber){
this.amount = amount;
this.face = Integer.toString(cNumber);
}
public void removed(){
isOpen = true;
face = "X";
}
public boolean isRemoved(){
return isOpen;
}
public int getAmount(){
return amount;
}
public String toString(){
return face;
}
public String getFace(){
return face;
}
}
import java.util.Collections;
import java.util.Arrays;
import java.util.List;
public class BriefcaseTest{
public static void main(String[] args){
Briefcase[] briefcase = new Briefcase[26];
List<Integer> amounts = Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26);
Collections.shuffle(amounts);
for(int i = 0 ; i<briefcase.length;i++){
int value = amounts.get(i);
briefcase[i] = new Briefcase(value,i+1);
}
for(int counter = 0 ; counter<briefcase.length; counter++){
System.out.print("\t "+briefcase[counter]+" ");
if(counter%5==4){
System.out.println();
}
}
}
}
How come if I remove my toString method in the briefcase class it give me this result
but if I have my toString method it gives me numbers, why is that? (I am experimenting btw)