These Directions Are Not Clear To Me

These Directions Are Not Clear To Me

I have to make a program that uses two files called coin. One file named coin and the other named coin tester. The directions in the book are confusing to me, but I still tried to do the assignment.

I have to make a program that uses two files called coin. One file named coin and the other named coin tester. The directions in the book are confusing to me, but I still tried to do the assignment.

Here are the directions that were given:

Create a Coin class that includes a variable faceUp that stores either a 0 for heads up or 1 for tails up, an accessor method named showFace() that returns a 0 if the coin is heads up or a 1 if the coin is tails up, and a modifier method named flipCoin() that assigns a random integer between 0 and 1, inclusive, to the variablefaceUp.

Test the class with the following client code:

public class CoinTester{
    public static void main(String[] args) {
        Coin nickel = new Coin();
        if (nickel.flipCoin() == 0) {
            System.out.println("Heads up!");
        } else {
            System.out.println("Tails up!");
        }
    }
}

Here is my code for the file named coin:

public class Coin {
    private int faceUp;

public Coin() {
    faceUp = (int)(Math.random() * 2);
}

public int showCoin() {
    return faceUp;
}

public void flipCoin() {
    faceUp = (int)(Math.random() * 2);
}

}

I know for sure I did it wrong because I'm confused and the program has syntax errors. I feel like it is not possible with the directions im given. The CoinTester is expecting a return method but I am not allowed to because of the directions.

java

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Java Core (2020) | Java for beginners | Brush up your Java Skills | Get Hired

In this video we will learn about all the major concepts that come under Java Core . The course is very carefully designed and is made with keeping simplicit...

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

How Java Became The Best Career Option for IT Jobs in 2020?

Join CETPA, India's best institute for Java online training and Certification Course. Enroll now to learn Core to Advanced Java & avail 50% discount on Java Online Course with Certificate.

Java Online Certifications Courses To Level Up Your Career In 2020

Join CETPA, India's best institute for Java online training and Certification Course. Enroll now to learn Core to Advanced Java & avail 50% discount on Java Online Course with Certificate.