1

I'm trying to use a method from another class called Digits but referring to it in a class called FourDigits. I've tried to create an instance variable by using the following code:

public class FourDigits


private Digits TwoDigitA;
private Digits TwoDigitB;

/**
 * Constructor for objects of class FourDigits
 */
public FourDigits()
{
    TwoDigitA = new Digits();
    TwoDigitB = new Digits();
    setValues();
    setIncrement();
    getDisplayString();
}

The first class, Digits:

public class Digits

private int value;
private int tooHigh;
private String displayString;


public Digits(int anyNum)
{
    value = 0;
    tooHigh=anyNum;
    displayString = "";
}

Thanks!

3 Answers 3

3

ok first, your class doesn't have { brackets.. don't know if this is a copy/paste error but well..

and second your constructor needs a int parameter

TwoDigitA = new Digits();

you don't specify an int here..

TwoDigitA = new Digits(12);

or remove the anyNum from

public Digits(int anyNum)
Sign up to request clarification or add additional context in comments.

Comments

0

The Digits constructor requires a parameter. Digits() doesn't exist.

Comments

0

Digits constructor takes an integer in your code... you don't give it any integers when you make the "twodigits" and it doesn't have a constructor with no arguments...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.