How to run method from a different object?
Hi,
I am making a simple card game and am having a problem running a method from a different object.
I have a class called decks which has a method call nextCard, I want to run this method from a class called dealer.
I understand the idea and think I am just stuck with the syntax.
Code:
public class dealer
{
private decks decks;
/**
* Constructor for objects of class dealer
*/
public dealer(decks newDeck)
{
decks = newDeck;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public void nextCard()
{
decks nextCard=decks.nextCard();
}
}
When I create a new instance of dealer I am able to select an instance of decks so all the information is inherited. But nextCard in dealer doesn't compile with the error "incompatible types - found void but expected decks".
Any help will be much appreciated.