0

I have an array of letters

public String[] letters = {"A","J","K","Q"};

and a method I tried creating to draw the letters.

public void drawLetterValue(Graphics pane, String[] someValue, int someX, int someY){

    someValue = letters;
    String aValue = String.valueOf(someValue);
    pane.drawString(aValue, someX, someY);
}

The array is declared in a class called Card (also referred to as "pileOne") along with the method, however I am trying to call the method in another class called Game (I'm trying to make a deck of cards program). When I try to draw the method, (ex):

pileOne.drawLetterValue(pane, pileOne.letters[0], 155, 90);

I get the error:

"The method drawLetterValue(Graphics, String[], int, int) in the type Card is not applicable for the arguments (Graphics, String, int, int)"

I'm confused because I'm calling letters as an array, yet the error I get tells me I'm only calling it as a string. Any help is appreciated, thanks!

Canvas
  • 5,779
  • 9
  • 55
  • 98

1 Answers1

0

The way you use the method

pileOne.drawLetterValue(pane, pileOne.letters[0], 155, 90);

uses the element 0 of the array as the second argument, so just a String, not an array of Strings. To pass an array, do this:

pileOne.drawLetterValue(pane, pileOne.letters, 155, 90);

[X] means "Xth element of the array" :-)

Kelevandos
  • 7,024
  • 2
  • 29
  • 46