非静态变量,不能引用

时间:2014-11-13 00:53:09

标签: java non-static

我正在做一个使用model-viewcontroller模式来实现一个简单的基于计时器的计数器的赋值。到目前为止,我相信我已经输入并修复了所有内容抛出错误,我不知道如何修复它。这是我在大学里的第一门Java课程,所以我很新。

我可以帮忙吗?

public class HW4Q3 {

    public class View {

        public void Display(int counter) {
            System.out.println(counter);
        }
    }

    public class Model extends View {

        private int counter = 0;
        private int init = 0;

        public Model(int value) {
            super();
            counter = value;
            init = value;
        }

        public void inc() {
            counter++;
            Display(counter);
        }

        public void reset();

        {
            counter = init;
        }
    }

    public class CounterController extends Model {

        private int start;
        private int end;

        public CounterController(int start, int end);

        {
            super(start);
            this.start = start;
            this.end = end;

        }

        public void Start() {
            for (int i = start; i < end; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    System.out.println("Stopped program.");
                }
                inc();
            }
            reset();
        }
    }

    public static void main(String[] args) {
        CounterController c = new CounterController(5, 15);

        c.Start();
        System.out.println("...Processing...");

    }

}

编译器(netBeans)说 CounterController c = new CounterController(5,15); 是我的错误

0 个答案:

没有答案