Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SICILIAGUERRABOT2020.JAVA
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package siciliaguerrabot2020;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.LinkedList;
- import java.util.StringTokenizer;
- /**
- *
- * @author Marco
- */
- public class SiciliaGuerraBot2020 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- LinkedList<Comune> comuni = new LinkedList<>();
- BufferedReader reader;
- StringTokenizer st;
- try {
- reader = new BufferedReader(new FileReader("data.txt"));
- String line = reader.readLine();
- while (line != null){
- line = reader.readLine();
- st = new StringTokenizer(line);
- comuni.add(new Comune(st.nextToken(), Integer.parseInt(st.nextToken()), new Centroide(Float.parseFloat(st.nextToken()), Float.parseFloat(st.nextToken()))));
- }
- } catch (IOException e){
- System.out.println("File non trovato");
- }
- for(Comune c : comuni){
- System.out.println(c);
- }
- }
- private static int getRandomNumberInRange(int min, int max) {
- if (min >= max) {
- throw new IllegalArgumentException("max must be greater than min");
- }
- return (int)(Math.random() * ((max - min) + 1)) + min;
- }
- }
- CENTROIDE.JAVA
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package siciliaguerrabot2020;
- /**
- *
- * @author Marco
- */
- public class Centroide {
- private float lat;
- private float lon;
- public Centroide(float lat, float lon) {
- this.lat = lat;
- this.lon = lon;
- }
- public float getLat() {
- return lat;
- }
- public float getLon() {
- return lon;
- }
- public Centroide(){
- lat = 0;
- lon = 0;
- }
- }
- COMUNE.JAVA
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package siciliaguerrabot2020;
- /**
- *
- * @author Marco
- */
- public class Comune {
- private boolean vivo;
- private String nome;
- private int pop;
- private Centroide pos;
- public Comune(String nome, int pop, Centroide pos) {
- this.nome = nome;
- this.pop = pop;
- this.pos = pos;
- }
- public Comune(){
- }
- public boolean isVivo() {
- return vivo;
- }
- public void setVivo(boolean vivo) {
- this.vivo = vivo;
- }
- public String getNome() {
- return nome;
- }
- public int getPop() {
- return pop;
- }
- public Centroide getPos() {
- return pos;
- }
- @Override
- public String toString() {
- return "Comune{" + "vivo=" + vivo + ", nome=" + nome + ", pop=" + pop + ", pos=" + pos + '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement