From bac55784cef70db13c04b5267110e430504511db Mon Sep 17 00:00:00 2001 From: orange Date: Fri, 23 Dec 2016 12:44:06 +0100 Subject: [PATCH] rm centro ricerca --- src/CentroRicerca/Constants.java | 6 - src/CentroRicerca/IllegalDateException.java | 10 -- .../IllegalPercentageException.java | 10 -- .../IncorrectLabelException.java | 10 -- src/CentroRicerca/IndustrialProject.java | 73 ---------- src/CentroRicerca/Project.java | 129 ----------------- src/CentroRicerca/ProjectTester.java | 45 ------ src/CentroRicerca/Projects.txt | 24 ---- src/CentroRicerca/ResearchCenter.java | 133 ------------------ src/CentroRicerca/ResearchCenterTester.java | 18 --- src/CentroRicerca/ResearchProject.java | 118 ---------------- 11 files changed, 576 deletions(-) delete mode 100644 src/CentroRicerca/Constants.java delete mode 100644 src/CentroRicerca/IllegalDateException.java delete mode 100644 src/CentroRicerca/IllegalPercentageException.java delete mode 100644 src/CentroRicerca/IncorrectLabelException.java delete mode 100644 src/CentroRicerca/IndustrialProject.java delete mode 100644 src/CentroRicerca/Project.java delete mode 100644 src/CentroRicerca/ProjectTester.java delete mode 100644 src/CentroRicerca/Projects.txt delete mode 100644 src/CentroRicerca/ResearchCenter.java delete mode 100644 src/CentroRicerca/ResearchCenterTester.java delete mode 100644 src/CentroRicerca/ResearchProject.java diff --git a/src/CentroRicerca/Constants.java b/src/CentroRicerca/Constants.java deleted file mode 100644 index 5ecf1f3..0000000 --- a/src/CentroRicerca/Constants.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.text.SimpleDateFormat; - -public class Constants { - public static final String DATE_FORMAT = "dd-MM-yyyy"; - public static final SimpleDateFormat S_DATE_FORMAT = new SimpleDateFormat(DATE_FORMAT); -} diff --git a/src/CentroRicerca/IllegalDateException.java b/src/CentroRicerca/IllegalDateException.java deleted file mode 100644 index a71ba56..0000000 --- a/src/CentroRicerca/IllegalDateException.java +++ /dev/null @@ -1,10 +0,0 @@ -public class IllegalDateException extends RuntimeException { - - public IllegalDateException() { - } - - public IllegalDateException(String msg) { - super(msg); - } - -} diff --git a/src/CentroRicerca/IllegalPercentageException.java b/src/CentroRicerca/IllegalPercentageException.java deleted file mode 100644 index ce071fe..0000000 --- a/src/CentroRicerca/IllegalPercentageException.java +++ /dev/null @@ -1,10 +0,0 @@ -public class IllegalPercentageException extends RuntimeException { - - public IllegalPercentageException() { - } - - public IllegalPercentageException(String msg) { - super(msg); - } - -} diff --git a/src/CentroRicerca/IncorrectLabelException.java b/src/CentroRicerca/IncorrectLabelException.java deleted file mode 100644 index 0a19b2b..0000000 --- a/src/CentroRicerca/IncorrectLabelException.java +++ /dev/null @@ -1,10 +0,0 @@ -public class IncorrectLabelException extends RuntimeException { - - public IncorrectLabelException() { - } - - public IncorrectLabelException(String msg) { - super(msg); - } - -} diff --git a/src/CentroRicerca/IndustrialProject.java b/src/CentroRicerca/IndustrialProject.java deleted file mode 100644 index 85cb4d1..0000000 --- a/src/CentroRicerca/IndustrialProject.java +++ /dev/null @@ -1,73 +0,0 @@ -import java.io.PrintStream; -import java.util.Date; -import java.util.Scanner; - -public class IndustrialProject extends Project { - - public IndustrialProject(String name, String description, double budget, Date start, Date end, String company, - double fundedPercentage) { - super(name, description, budget, start, end); - this.company = company; - this.fundedPercentage = fundedPercentage; - } - - public String getCompany() { - return company; - } - - public void setCompany(String company) { - this.company = company; - } - - public double getFundedPercentage() { - return fundedPercentage; - } - - public void setFundedPercentage(double fundedPercentage) { - this.fundedPercentage = fundedPercentage; - } - - public static IndustrialProject read(Scanner sc) { - String company; - double fundingPercentage; - - Project p = Project.read(sc); - - if (!sc.hasNextLine()) { - return null; - } - company = sc.nextLine(); - - if (!sc.hasNextLine()) { - return null; - } - try { - fundingPercentage = Double.parseDouble(sc.nextLine()); - if (fundingPercentage < 0 || fundingPercentage > 100) { - throw new IllegalPercentageException("Percentage value is out of bounds!"); - } - } catch (NumberFormatException e) { - System.err.println("An exception occurred while parsing funding percentage, project " + p.getName()); - System.err.println("Funding percentage will be assigned default value.."); - fundingPercentage = 0; - } catch (IllegalPercentageException e) { - System.err.println("An exception occurred while parsing funding percentage, project " + p.getName()); - System.err.println(e.getMessage()); - System.err.println("Funding percentage will be assigned default value.."); - fundingPercentage = 0; - } - - return new IndustrialProject(p.getName(), p.getDescription(), p.getBudget(), p.getStart(), p.getEnd(), company, - fundingPercentage); - } - - public void print(PrintStream ps) { - super.print(ps); - ps.println(company); - ps.println(fundedPercentage); - } - - private String company; - private double fundedPercentage; - -} diff --git a/src/CentroRicerca/Project.java b/src/CentroRicerca/Project.java deleted file mode 100644 index 3797743..0000000 --- a/src/CentroRicerca/Project.java +++ /dev/null @@ -1,129 +0,0 @@ -import java.io.PrintStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Scanner; - -public class Project { - - public Project(String name, String description, double budget, Date start, Date end) { - this.name = name; - this.description = description; - this.budget = budget; - this.start = start; - this.end = end; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public double getBudget() { - return budget; - } - - public void setBudget(double budget) { - this.budget = budget; - } - - public Date getStart() { - return start; - } - - public void setStart(Date start) { - this.start = start; - } - - public Date getEnd() { - return end; - } - - public void setEnd(Date end) { - this.end = end; - } - - public static Project read(Scanner sc) { - String name, description; - double budget; - Date start; - Date end; - - SimpleDateFormat df = Constants.S_DATE_FORMAT; - - if (!sc.hasNextLine()) { - return null; - } - name = sc.nextLine(); - - if (!sc.hasNextLine()) { - return null; - } - description = sc.nextLine(); - - if (!sc.hasNextLine()) { - return null; - } - try { - budget = Double.parseDouble(sc.nextLine()); - } catch (NumberFormatException e) { - System.err.println("An exception occurred while parsing budget, project " + name); - System.err.println("Budget will be assigned default value..."); - budget = 0; - } - - try { - start = df.parse(sc.nextLine()); - } catch (ParseException e) { - System.err.println("An exception occurred while parsing start date, project " + name); - System.err.println("Start date will be assigned default system date..."); - start = new Date(); - } - - try { - end = df.parse(sc.nextLine()); - if (end.before(start)) { - throw new IllegalDateException("End date is before start date!"); - } - } catch (ParseException e) { - System.err.println("An exception occurred while parsing end date, project " + name); - System.err.println("End date will be assigned default system date..."); - end = new Date(); - } catch (IllegalDateException e) { - System.err.println("An exception occurred while parsing end date, project " + name); - System.err.println(e.getMessage()); - System.err.println("End date will be assigned default system date..."); - end = new Date(); - } - - return new Project(name, description, budget, start, end); - } - - public void print(PrintStream ps) { - SimpleDateFormat df = Constants.S_DATE_FORMAT; - - ps.println(name); - ps.println(description); - ps.println(budget); - ps.println(df.format(start)); - ps.println(df.format(end)); - } - - private String name; - private String description; - private double budget; - private Date start; - private Date end; - -} diff --git a/src/CentroRicerca/ProjectTester.java b/src/CentroRicerca/ProjectTester.java deleted file mode 100644 index d359ce0..0000000 --- a/src/CentroRicerca/ProjectTester.java +++ /dev/null @@ -1,45 +0,0 @@ -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Scanner; - -public class ProjectTester { - - public static void main(String[] args) throws FileNotFoundException { - Scanner sc = new Scanner(new File("Projects.txt")); - Project project = null; - - String type = sc.nextLine(); - //type = sc.nextLine(); - - while (type != null){ - try { - if(!type.equals("Ricerca") && !type.equals("Industria")) { - throw new IncorrectLabelException("Label is not \"Industria\" or \"Ricerca\"!"); - } - - if(type.equals("Ricerca")) { - project = ResearchProject.read(sc); - } else if(type.equals("Industria")) { - project = IndustrialProject.read(sc); - } - - if(project != null) { - project.print(System.out); - } - - } - catch(IncorrectLabelException e) { - System.err.println("An exception occurred while reading project label \"" + type + "\""); - System.err.println(e.getMessage()); - System.err.println("All next line different from Industria or Ricerca will be skipped..."); - - while(!type.equals("Ricerca") && !type.equals("Industria") && sc.hasNextLine()) { - type = sc.nextLine(); - } - if(!sc.hasNextLine()) { - type = null; - } - } - } - } -} diff --git a/src/CentroRicerca/Projects.txt b/src/CentroRicerca/Projects.txt deleted file mode 100644 index 6ea8e64..0000000 --- a/src/CentroRicerca/Projects.txt +++ /dev/null @@ -1,24 +0,0 @@ -Ricerca -Eureka -Definizione metodi di analisi -3000000 -10-04-2004 -10-04-2007 -Comunità europea -IV programma quadro -Industria -L2eL -Evoluzione di processi di business -1000000 -11-11-2002 -10-11-2004 -EDS -20 -Ricerca -CdC -Creazione di un’infrastruttura di ricerca -5000000 -01-03-2003 -28-02-2006 -Regione Campania -Centri di Competenza diff --git a/src/CentroRicerca/ResearchCenter.java b/src/CentroRicerca/ResearchCenter.java deleted file mode 100644 index ab36e1c..0000000 --- a/src/CentroRicerca/ResearchCenter.java +++ /dev/null @@ -1,133 +0,0 @@ -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.Scanner; - -public class ResearchCenter { - - public ResearchCenter(Scanner sc) { - projects = new ArrayList(); - - Project p = readProject(sc); - while (p != null) { - projects.add(p); - p = readProject(sc); - } - } - - private ResearchCenter(ArrayList projects) { - this.projects = projects; - } - - private Project readProject(Scanner sc) { - Project project = null; - - if (!sc.hasNextLine()) { - return null; - } - String type = sc.nextLine(); - - while (type != null) { - try { - if (!type.equals("Ricerca") && !type.equals("Industria")) { - throw new IncorrectLabelException("Label is not \"Industria\" or \"Ricerca\"!"); - } - - if (type.equals("Ricerca")) { - project = ResearchProject.read(sc); - } else if (type.equals("Industria")) { - project = IndustrialProject.read(sc); - } - - return project; - - } catch (IncorrectLabelException e) { - System.err.println("An exception occurred while reading project label \"" + type + "\""); - System.err.println(e.getMessage()); - System.err.println("All next line different from Industria or Ricerca will be skipped..."); - - while (!type.equals("Ricerca") && !type.equals("Industria") && sc.hasNextLine()) { - type = sc.nextLine(); - } - if (!sc.hasNextLine()) { - type = null; - } - } - } - - return null; - } - - public ResearchCenter filterByPreviousDate(Date date) { - ArrayList projectsFilter = new ArrayList(); - - for (Project p : projects) { - if (p.getEnd().before(date)) { - projectsFilter.add(p); - } - } - - return new ResearchCenter(projectsFilter); - } - - public ResearchCenter filterByNextDate(Date date) { - ArrayList projectsFilter = new ArrayList(); - - for (Project p : projects) { - if (p.getStart().after(date)) { - projectsFilter.add(p); - } - } - - return new ResearchCenter(projectsFilter); - } - - public ResearchCenter researchProjectFilter(){ - ArrayList projectsFilter = new ArrayList(); - - for(Project p: project) - if(p istanceof ResearchProject) - projectsFilter.add(p); - - return new ResearchCenter(projectsFilter); - } - - public void sortByName() { - int i, j = 0; - boolean done = false; - - while (!done && j < projects.size() - 1) { - done = true; - - for (i = 0; i < projects.size() - j - 1; i++) { - if (projects.get(i).getName().compareTo(projects.get(i + 1).getName()) > 0) { - swap(i, i + 1); - done = false; - } - } - - j++; - } - } - - private void swap(int i, int j) { - Project temp = projects.get(i); - projects.set(i, projects.get(j)); - projects.set(j, temp); - } - - public void print(PrintStream ps) { - for (Project p : projects) { - if (p instanceof ResearchProject) { - ps.println("Ricerca"); - } else { - ps.println("Industria"); - } - - p.print(ps); - } - } - - private ArrayList projects; - -} diff --git a/src/CentroRicerca/ResearchCenterTester.java b/src/CentroRicerca/ResearchCenterTester.java deleted file mode 100644 index f10dc50..0000000 --- a/src/CentroRicerca/ResearchCenterTester.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Scanner; - -public class ResearchCenterTester { - - public static void main(String[] args) throws FileNotFoundException { - Scanner sc = new Scanner(new File("Projects.txt")); - ResearchCenter rc = new ResearchCenter(sc); - - rc.print(System.out); - System.out.println("*****"); - - rc.sortByName(); - rc.print(System.out); - } - -} diff --git a/src/CentroRicerca/ResearchProject.java b/src/CentroRicerca/ResearchProject.java deleted file mode 100644 index 0f8dfce..0000000 --- a/src/CentroRicerca/ResearchProject.java +++ /dev/null @@ -1,118 +0,0 @@ -import java.io.PrintStream; -import java.util.Date; -import java.util.Scanner; - -public class ResearchProject extends Project { - - public ResearchProject(String name, String description, double budget, Date start, Date end, String fundingBody, - String fundingLaw) { - super(name, description, budget, start, end); - this.fundingBody = fundingBody; - this.fundingLaw = fundingLaw; - } - - public String getFundingBody() { - return fundingBody; - } - - public void setFundingBody(String fundingBody) { - this.fundingBody = fundingBody; - } - - public String getFundingLaw() { - return fundingLaw; - } - - public void setFundingLaw(String fundingLaw) { - this.fundingLaw = fundingLaw; - } - - public static ResearchProject read(Scanner sc) { - String fundingBody, fundingLaw; - - Project p = Project.read(sc); - - if (!sc.hasNextLine()) { - return null; - } - fundingBody = sc.nextLine(); - - if (!sc.hasNextLine()) { - return null; - } - fundingLaw = sc.nextLine(); - - return new ResearchProject(p.getName(), p.getDescription(), p.getBudget(), p.getStart(), p.getEnd(), - fundingBody, fundingLaw); - } - - public void print(PrintStream ps) { - super.print(ps); - ps.println(fundingBody); - ps.println(fundingLaw); - } - - private String fundingBody; - private String fundingLaw; - -} -package com.gmail.zurlo.michelef.classi; - -import java.io.PrintStream; -import java.util.Date; -import java.util.Scanner; - -public class ResearchProject extends Project { - - public ResearchProject(String name, String description, double budget, Date start, Date end, String fundingBody, - String fundingLaw) { - super(name, description, budget, start, end); - this.fundingBody = fundingBody; - this.fundingLaw = fundingLaw; - } - - public String getFundingBody() { - return fundingBody; - } - - public void setFundingBody(String fundingBody) { - this.fundingBody = fundingBody; - } - - public String getFundingLaw() { - return fundingLaw; - } - - public void setFundingLaw(String fundingLaw) { - this.fundingLaw = fundingLaw; - } - - public static ResearchProject read(Scanner sc) { - String fundingBody, fundingLaw; - - Project p = Project.read(sc); - - if (!sc.hasNextLine()) { - return null; - } - fundingBody = sc.nextLine(); - - if (!sc.hasNextLine()) { - return null; - } - fundingLaw = sc.nextLine(); - - return new ResearchProject(p.getName(), p.getDescription(), p.getBudget(), p.getStart(), p.getEnd(), - fundingBody, fundingLaw); - } - - public void print(PrintStream ps) { - super.print(ps); - ps.println(fundingBody); - ps.println(fundingLaw); - } - - private String fundingBody; - private String fundingLaw; - -} \ No newline at end of file