Recommand · November 24, 2021 0

How to print methods from other classes

Closed. This question needs debugging details. It is not currently accepting answers.


Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 10 mins ago.

Improve this question

I have some code for a game of elevens;

public void elevensBoard() {
        cards = new Card[BOARD_SIZE];
        deck = new Deck(RANKS, SUITS, POINT_VALUES);
        if (I_AM_DEBUGGING) {
            System.out.println(deck);
            System.out.println("----------");
        }
        dealMyCards();
    }

    public void newGame() {
        deck.shuffle();
        dealMyCards();
    }

the code all works correctly but im trying to print the output of dealMyCards using the following code is a seperate class;

public class Play {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println("Select Option: \n");
        System.out.println("1. Play Game");
        System.out.println("2. Exit Game");
        switch (sc.nextInt()) {
            case 1:
            System.out.println(newGame().dealMyCards());
            case 2:
            System.exit(0);
        }
    }
}

im getting the error below and not sure how to solve it;

The method newGame() is undefined for the type Play

thanks