Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98524

I don't know (Unresolved compilation problem:) [closed]

$
0
0

I just started study java and vsc. I aleardy searched and saw all of questions that have 'Unresolved compilation problem:'. But I can't find my question.

This is my error message :

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
        name cannot be resolved or is not a field

        at Student.<init>(Student.java:10)
        at ShowTrans.main(ShowTrans.java:3)

I installed all the extends, debugging programs.

Student class

    public class Student {

    String studentName;
    int money;

    public Student() {
    }

    public Student(String name, int money) {
        this.name = studentName;
        this.money = money;
    }

    public void takeBus(Bus bus) {
        bus.take(1000);
        money -= 1000;
    }

    public void takeSubway(Subway subway) {
        subway.take(1500);
        money -= 1500;
    }

    public void showInfo() {
        System.out.println(studentName + "left money : " + money");
    }
}

Bus class

public class Bus {
int money;
int busNumber;
int passenger = 0;

public Bus() {
}

public Bus(int num) {
    this.num = busNumber;
}

public void take(int money) {
    this.money += money;
    passenger++;
}

public void showInfo() {
    System.out.println("Bus" + busNumber + "'s passenger is" + passenger + ", money is" + money");
}}

ShowTrans class

public class ShowTrans {
public static void main(String[] args) {
    Student james = new Student("James", 10000);

    Bus bus100 = new Bus(100);
    james.takeBus(bus100);
    james.showInfo();
    bus100.showInfo();
}}

Viewing all articles
Browse latest Browse all 98524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>