-1

I created a method class that will test the months and days and tell you what the season is. I'm creating a tester class but for some reason it won't recognize the getSeason() class from the methods but it shows they are connected.

Method Code:

public class Season {
    private String season;

    public String getSeason(int month, int day) {
        if (month == 1 || month == 2 || month == 3) {
            season = "Winter";
        } else if (month == 4 || month == 5 || month == 6) {
            season = "Spring";
        } else if (month == 7 || month == 8 || month == 9) {
            season = "Summer";
        } else if (month == 10 || month == 11 || month == 12) {
            season = "Fall";
        }

        if (month % 3 == 0 && day >= 21) {
            if (season.equals("Winter")) {
                season = "Spring";
            } else if (season.equals("Spring")) {
                season = "Summer";
            } else if (season.equals("Summer")) {
                season = "Fall";
            } else {
                season = "Winter";
            }
        }
        return season;
    }
}

Tester Code:

import java.util.Scanner;

public class SeasonTester {
    public static void main(String[] args) {
        Season s = new getSeason();
        Scanner input = new Scanner(System.in);
    }
}

I get a cannot get symbol - class getSeason error when I compile

Trevn Jones
  • 341
  • 2
  • 4
  • 11

1 Answers1

0

You are calling a method instead of constructor here:

    Season s = new getSeason();

should be

    Season s = new Season();

Then you can call isntance method using this:

s.getSeason();
Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136