Weather Program Specification and Pseudo Code

Specification Sheet

Program Name: Weather Program

Description:

This program models weather conditions for different cities by instantiating weather objects, updating their attributes, and calculating weather-related values.

Classes and Methods:

Class: Weather

Class: WeatherMain

Creates Objects:

weather1 = new Weather();
weather2 = new Weather("New York", 75.5);
weather3 = new Weather("Los Angeles", 85.0, 40, false);
weather4 = new Weather("Chicago", 30.0, 85, true, 'R');
    

Calls Methods for Each Object:

Pseudo Code

BEGIN PROGRAM

CLASS Weather:
    DECLARE city AS STRING
    DECLARE temperature AS DOUBLE
    DECLARE humidity AS INTEGER
    DECLARE isStormy AS BOOLEAN
    DECLARE weatherSymbol AS CHAR

    METHOD Weather() # Default Constructor
        SET city = "Unknown"
        SET temperature = 0.0
        SET humidity = 50
        SET isStormy = false
        SET weatherSymbol = 'C'
    END METHOD

    METHOD Weather(city, temperature)
        SET city = city
        SET temperature = temperature
        SET humidity = 50
        SET isStormy = false
        SET weatherSymbol = 'S'
    END METHOD

    METHOD Weather(city, temperature, humidity, isStormy)
        SET city = city
        SET temperature = temperature
        SET humidity = humidity
        SET isStormy = isStormy
        SET weatherSymbol = IF isStormy THEN 'R' ELSE 'C'
    END METHOD

    METHOD updateCity(newCity)
        SET city = newCity
    END METHOD

    METHOD calculateHeatIndex()
        RETURN temperature + (humidity * 0.1)
    END METHOD

    METHOD isExtremeWeather()
        RETURN (temperature > 100 OR temperature < 32 OR humidity > 90 OR isStormy)
    END METHOD

END CLASS

CLASS WeatherMain:
    CREATE weather1 AS Weather()
    CREATE weather2 AS Weather("New York", 75.5)
    CREATE weather3 AS Weather("Los Angeles", 85.0, 40, false)
    CREATE weather4 AS Weather("Chicago", 30.0, 85, true, 'R')
END CLASS

END PROGRAM
    

Files to drop off into google classroom.


You will drop off 4 files into Google Classroom:
	• Your files will be: (Remember the java program is dropped off first.)
		• PX_lastname_Weather.java (Java program that is instantiated)
		• PX_lastname_WeatherTester.java (Java program that instantiates the object)
		• PX_lastname_Weather.png (Screenshot inside Eclipse)
		• PX_lastname_Weather.mp4 (Video running the program)

            
                 If you do not understand this assignment,
                 ask Mr. Cusack and/or attend tutorials.