i have the problem of not being able to call my own methods in object elements of an array
Here is the code for the part of the code with the array:
public class CardRules {
private Object cardArray[];
public CardRules(Object cardArrayCopy[]){
cardArray = cardArrayCopy;
multiples();
}
public void multiples(){
for(Object ArrayElement: cardArray){
System.out.println(ArrayElement);
}
}
}
And for the Card Object:
public class Card {
private int rank;
private int suit;
private String Stringrank[] = {"Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
private String Stringsuit[] = {"Spades", "Hearts", "Diamonds", "Clubs"};
public static int CardNo = 0;
public Card(int cardDetails[]){
rank = cardDetails[1];
suit = cardDetails[0];
CardNo++;
}
public String getCard(){
return ("Card: " + Stringrank[rank] + " Of " + Stringsuit[suit]);
}
public int getRank(){
return rank;
}
public int getSuit(){
return suit;
}
}
The output for this part of the program is the hash codes, Card@9304b1 Card@190d11 Card@a90653 Card@de6ced Card@c17164
i would like to put something like or similar
System.out.println(ArrayElement.getRank());
does anyone have any ideas as to why this is happening?
btw the array is copied from an ArrayList in another class using the premade .toArray() method