I have no idea what I am doing wrong. I am writing a Java program with cards and hands classes. When I run my main program it just prints out null
import java.util.ArrayList;
public class Hand {
//Field
public String [] array;
private ArrayList<String> cards = new ArrayList<String>();
//Constructor
public Hand(String [] array) {
this.array = array;
}
//Methods
public void addCard(String card){
cards.add(card);
}
public void removeCard(String card){
cards.remove(card);
}
public static void printHand (){
System.out.print(Card.printCard());
}
public class Card {
//fields
public static String num2rank, rank2abbrv, num2suit, suit2abbrv;
//constructor
public Card (String num2rank,String rank2abbrv,String num2suit,
String suit2abbrv){
this.num2suit = num2suit;
this.num2rank = num2rank;
this.rank2abbrv = rank2abbrv;
this.suit2abbrv = suit2abbrv;
}
//Methods
public static String getRank(){
return num2rank;
}
public static String getSuit(){
return num2suit;
}
public static String getName(){
String result = "";
String rank = getRank();
String suit = getSuit();
result += rank + " of " + suit;
return result;
}
public static String getAbbrev(){
String result = "";
String rank = rank2abbrv;
String suit = suit2abbrv;
result += rank + suit;
return result;
}
public static String printCard(){
String results = "";
results += "Printing Hand: " + getAbbrev();
results += "\n" + getName();
return results;
}
}
public class main {
public static void main(String[] args) {
Hand h = new Hand((new String []{"3c", "4s","5d","6h","7h"}));
h.printHand();
}
}
These are both my hand and card classes. The rank and suit class is just a case statement of the cards and what their suit and rank are. When I run my main is when it prints out null. I want it to print out for example "7s" and "seven of hearts"