Create a new subdirectory named cards and change to that directory.
Create a new class named Card. Add a constructor and two getter methods.
public class Card {
private int rank;
private int suit;
public int getRank(){
return this.rank;
}
public int getSuit(){
return this.suit;
}
public Card(int rank, int suit){
this.rank = rank;
this.suit = suit;
}
}
Create a new Class named CardDriver.
Add a main method that creates a Card and then tests its values
public class CardDriver {
public static void main(String[] args){
Card myCard = new Card(1,2);
System.out.println(myCard.getRank());
System.out.println(myCard.getSuit());
}
}
Compile CardDriver.java and run the program. Note that compiling CardDriver also results in Card being compiled.