Teams Winter 2011/team2/lab2

From CDOT Wiki
Revision as of 21:54, 17 February 2011 by Scborges (talk | contribs) (Created page with '=Tutorial= ==Prerequisites== * Download [http://www.eclipse.org/downloads/packages/eclipse-classic-361/heliossr1 Eclipse Classic] ==Creating and Setting the Interface Bundle== *R…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Tutorial

Prerequisites

Creating and Setting the Interface Bundle

  • Run Eclipse
  • Select/Enter your preferred workspace in the text box provided and click okay

Workspace2T2.png

  • After Eclipse has completed loaded, create a plug-in by clicking on "File" on the menu bar then scroll to New->Project->Plug-in
  • Enter the following information that is seen in the image below

PluginT2.png

  • Click Next
  • Plugin2T2.png
  • Click Finish
  • Now open the src folder, right-click on the pre-created bundle, and create a class called "Weather" and an interface called "WeatherSystem"
  • Copy and paste the following code to their respective file

Weather

package ecl.team2.lab2.weather;

public class Weather {
    private String city;
    private float tempInCelcius;
    private float rainInMM;
    private float snowInMM;
    private float windspeedInKM;
    private char windDirection;
   
    public Weather(String pcity, float ptemp, float prain, float psnow, float pwspeed, char pwdirection){
        this.setCity(pcity);
        this.setTempInCelcius(ptemp);
        this.setRainInMM(prain);
        this.setSnowInMM(psnow);
        this.setWindspeedInKM(pwspeed);
        this.setWindDirection(pwdirection);
    }
   
   
    public void setWindDirection(char windDirection) {
        this.windDirection = windDirection;
    }

    public char getWindDirection() {
        return windDirection;
    }



    public void setWindspeedInKM(float windspeedInKM) {
        this.windspeedInKM = windspeedInKM;
    }



    public float getWindspeedInKM() {
        return windspeedInKM;
    }



    public void setSnowInMM(float snowInMM) {
        this.snowInMM = snowInMM;
    }



    public float getSnowInMM() {
        return snowInMM;
    }



    public void setRainInMM(float rainInMM) {
        this.rainInMM = rainInMM;
    }



    public float getRainInMM() {
        return rainInMM;
    }



    public void setTempInCelcius(float tempInCelcius) {
        this.tempInCelcius = tempInCelcius;
    }



    public float getTempInCelcius() {
        return tempInCelcius;
    }



    public void setCity(String city) {
        this.city = city;
    }



    public String getCity() {
        return city;
    }
}

WeatherSystem

package ecl.team2.lab2.weather;

public interface WeatherSystem {
    Weather getWeather(String city) throws Exception;
}
  • Save and close both files and now open the manifest file

ManiT2.png

  • Click on the runtime tab then click on add in the "export packages" panel.
  • click on the ecl.... package and click okay

[[File:Mani2T2.png]