using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WillemsWeerWachter { public class KiteForecast : IComparable{ protected static TimeSpan kiteStartTime = new TimeSpan(10, 0, 0); protected static TimeSpan kiteEndTime = new TimeSpan(18, 0, 0); protected int id; protected DateTime date; protected int windBeaufort; protected int windDirectionId; protected double temperatureMinimum; protected double temperatureAfternoon; protected double percentageSun; protected double percentageRain; protected DateTime highTide1Moment; protected double highTide1WaterPosition; protected DateTime highTide2Moment; protected double highTide2WaterPosition; protected DateTime lowTide1Moment; protected double lowTide1WaterPosition; protected DateTime lowTide2Moment; protected double lowTide2WaterPosition; protected bool warnedWillem; public int Id { get { return id; } set { id = value; } } public DateTime Date { get { return date; } set { date = value; } } public int WindBeaufort { get { return windBeaufort; } set { windBeaufort = value; } } public int WindDirectionId { get { return windDirectionId; } set { windDirectionId = value; } } public WindDirection WindDirection { get { return (WindDirection)Enum.ToObject(typeof(WindDirection), WindDirectionId); } set { windDirectionId = (int)value; } } public double TemperatureMinimum { get { return temperatureMinimum; } set { temperatureMinimum = value; } } public double TemperatureAfternoon { get { return temperatureAfternoon; } set { temperatureAfternoon = value; } } public double PercentageSun { get { return percentageSun; } set { percentageSun = value; } } public double PercentageRain { get { return percentageRain; } set { percentageRain = value; } } public DateTime HighTide1Moment { get { return highTide1Moment; } set { highTide1Moment = value; } } public double HighTide1WaterPosition { get { return highTide1WaterPosition; } set { highTide1WaterPosition = value; } } public DateTime HighTide2Moment { get { return highTide2Moment; } set { highTide2Moment = value; } } public double HighTide2WaterPosition { get { return highTide2WaterPosition; } set { highTide2WaterPosition = value; } } public DateTime LowTide1Moment { get { return lowTide1Moment; } set { lowTide1Moment = value; } } public double LowTide1WaterPosition { get { return lowTide1WaterPosition; } set { lowTide1WaterPosition = value; } } public DateTime LowTide2Moment { get { return lowTide2Moment; } set { lowTide2Moment = value; } } public double LowTide2WaterPosition { get { return lowTide2WaterPosition; } set { lowTide2WaterPosition = value; } } public bool WarnedWillem { get { return warnedWillem; } set { warnedWillem = value; } } public double getConditionsQuality() { double score = 0 ; if(WindBeaufort<=2){ score = score - 1000; } else if (WindBeaufort == 3) { score = score + 25; } else if (WindBeaufort == 4) { score = score + 50; } else if (WindBeaufort == 5 || WindBeaufort == 6) { score = score + 100; } else if (WindBeaufort >= 7) { score = score + 50; } if (WindDirection == WindDirection.WEST || WindDirection == WindDirection.NORTH_WEST || WindDirection == WindDirection.SOUTH_WEST) { score = score + 100; } else if (WindDirection == WindDirection.EAST || WindDirection == WindDirection.NORTH_EAST || WindDirection == WindDirection.SOUTH_EAST) { score = score + 50; } else { score = score - 100; } if (PercentageRain <= 30) { score = score + 50; } else if (PercentageRain >= 80) { score = score - 50; } if(LowTide1Moment.TimeOfDay >= kiteStartTime && LowTide1Moment.TimeOfDay <= kiteEndTime){ score += 50; } if (LowTide2Moment.TimeOfDay >= kiteStartTime && LowTide2Moment.TimeOfDay <= kiteEndTime) { score += 50; } if (HighTide1Moment.TimeOfDay >= kiteStartTime && HighTide1Moment.TimeOfDay <= kiteEndTime) { score -= 25; } if (HighTide1Moment.TimeOfDay >= kiteStartTime && HighTide2Moment.TimeOfDay <= kiteEndTime) { score -= 25; } if (score < 0) { score = 0; } else if (score > 200) { score = 200; } return Math.Round(score/2); } public int CompareTo(object obj) { if (!(obj is KiteForecast)) { throw new InvalidCastException("This object is not of type WeatherForecast"); } KiteForecast other = (KiteForecast)obj; int compareResult = this.Date.CompareTo(other.Date); if (compareResult == 0) { return this.Id.CompareTo(other.Id); } return compareResult; } } public enum WindDirection { NORTH=0, NORTH_EAST=1, EAST=2, SOUTH_EAST=3, SOUTH=4, SOUTH_WEST=5, WEST=6, NORTH_WEST=7 } }