I can not cope with the design of the object model. You only need to draw the UML diagram, not the programming itself. If there is no opportunity to really help with advice, can anyone advise a good book or article, there are many voluminous books and I have to complete the task in a week ... therefore I hope for more specific help here.

Given:

Different weather stations in different cities measure different factors: temperature (° C), air humidity (%), amount of precipitation (mm / sq.m), wind speed (m / s), wind direction (W, W, W, and s) . Measurements are performed in an equal time interval (every 60 min.). It is assumed that the measurements are available in the file that is in the directory that should be configured in the external config file.

All data is aggregated and can be displayed in simple reports:

  • output of all values ​​at the weather station
  • output of all values ​​of a specific factor (for example, temperature) at a weather station
  • output of the minimum / maximum value of a certain factor and station (for example, the maximum temperature in Moscow)

Make a model of the program - application design:

  • object model
  • data layer
  • Services
  • helper classes and methods

Data format of the incoming file: date, time, city, team measurement, unit type, measure, value

  • only the design of the object model? - Senior Pomidor
  • do you know what is DAO? - Senior Pomidor
  • I know what DAO is. Initially solved the problem through a single object Measurment and DAO. But they returned my decision to me ... if not deliberate. They said Measurment divided into many objects to use enum by type of measurement. Ie somehow construct the application with maximum flexibility. Here already there was not enough brains - Alexander Dermenzhi
  • But can you send in your old code so that you will not make the same error here? - Senior Pomidor
  • github.com/Dermenji/Weather/tree/master/src/com/sirma/weather I have there and some kind of implementation of specific methods. But she is not interested in the case. Only the skeleton itself and the structure of classes / methods. - Alexander Dermenzhi

1 answer 1

painted as it should be. so ok? Next, use your classes to fill in everything. So much for scalability, and abstraction, and dao, and services, the format of the input file data

package oop.items; /** * Created by sahakyan on 6/24/2016. */ public class City { private String name; private Factors factors; public City(String name, Factors factors) { this.name = name; this.factors = factors; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Factors getFactors() { return factors; } public void setFactors(Factors factors) { this.factors = factors; } @Override public String toString() { return "City{" + "name='" + name + '\'' + ", factors=" + factors.toString() + '}'; } } 

2

 package oop.items; import java.util.*; /** * Created by sahakyan on 6/24/2016. */ public class Factors { private int temperature; /** * влажность воздуха */ private int airHumidity; /** * количество осадков */ private Rainfall rainfall; /** * скорость ветра */ private WindSpeed windSpeed; /** * направление ветра */ private WindDirection windDirection; /** * интервал времени */ private Calendar interval; public Factors(int temperature, int airHumidity, Rainfall rainfall, WindSpeed windSpeed, WindDirection windDirection, Calendar interval) { this.temperature = temperature; this.airHumidity = airHumidity; this.rainfall = rainfall; this.windSpeed = windSpeed; this.windDirection = windDirection; this.interval = interval; } public int getTemperature() { return temperature; } public void setTemperature(int temperature) { this.temperature = temperature; } public int getAirHumidity() { return airHumidity; } public void setAirHumidity(int airHumidity) { this.airHumidity = airHumidity; } public Rainfall getRainfall() { return rainfall; } public void setRainfall(Rainfall rainfall) { this.rainfall = rainfall; } public WindSpeed getWindSpeed() { return windSpeed; } public void setWindSpeed(WindSpeed windSpeed) { this.windSpeed = windSpeed; } public WindDirection getWindDirection() { return windDirection; } public void setWindDirection(WindDirection windDirection) { this.windDirection = windDirection; } public Calendar getInterval() { return interval; } public void setInterval(Calendar interval) { this.interval = interval; } @Override public String toString() { return "Factors{" + "temperature=" + temperature + ", airHumidity=" + airHumidity + ", rainfall=" + rainfall.toString() + ", windSpeed=" + windSpeed.toString() + ", windDirection=" + windDirection + ", interval=" + interval.toString() + '}'; } } 

3

 package oop.items; /** * Created by sahakyan on 6/24/2016. */ public class Rainfall { private int value; private String type; public Rainfall(int value, String type) { this.value = value; this.type = type; } public int getValue() { return value; } public void setValue(int value) { this.value = value; } public String getType() { return type; } public void setType(String type) { this.type = type; } @Override public String toString() { return "Rainfall{" + "value=" + value + ", type='" + type + '\'' + '}'; } } 

four

 package oop.items; /** * Created by sahakyan on 6/24/2016. */ public enum WindDirection { EAST, WEST, SOUTH, NORTH } 

five

 package oop.items; /** * Created by sahakyan on 6/24/2016. */ public class WindSpeed { private int value; private String type; public WindSpeed(int value, String type) { this.value = value; this.type = type; } public int getValue() { return value; } public void setValue(int value) { this.value = value; } public String getType() { return type; } public void setType(String type) { this.type = type; } @Override public String toString() { return "WindSpeed{" + "value=" + value + ", type='" + type + '\'' + '}'; } } 

6

 package oop.services; import oop.dao.*; import oop.items.*; import java.util.*; /** * Created by sahakyan on 6/24/2016. */ public class FactorsService extends AbstractController { private ArrayList<City> cityArrayList = new ArrayList<City>(); public FactorsService() { } public List getAll() { return cityArrayList; } public Object update(Object entity) { return null; } public Object add(Object entity) { return null; } public Object getEntityById(Object id) { return null; } public Object getByName(Object name) { return null; } public boolean remove(Object id) { return false; } public boolean create(Object entity) { return false; } } 

7

 package oop.dao; import java.util.*; /** * Created by sahakyan on 6/24/2016. */ public abstract class AbstractController<E, K> { public abstract List<E> getAll(); public abstract E update(E entity); public abstract E add(E entity); public abstract E getEntityById(K id); public abstract E getByName(K name); public abstract boolean remove(K id); public abstract boolean create(E entity); } 
  • Cool, thank you very much !!! - Alexander Dermenzhi
  • Please advise the book efficiently, how to learn to think so and be able to create such structures. - Alexander Dermenzhi
  • can Steve McConnell. Perfect code. 2007 (In English - Code Complete) Design Patterns to pull up - Senior Pomidor