diff --git a/src/CentroRicerca/Constants.java b/src/CentroRicerca/Constants.java index af8b72f..5ecf1f3 100644 --- a/src/CentroRicerca/Constants.java +++ b/src/CentroRicerca/Constants.java @@ -1,5 +1,3 @@ -package com.gmail.zurlo.michelef.util; - import java.text.SimpleDateFormat; public class Constants { diff --git a/src/CentroRicerca/IllegalDateException.java b/src/CentroRicerca/IllegalDateException.java index 7176c94..a71ba56 100644 --- a/src/CentroRicerca/IllegalDateException.java +++ b/src/CentroRicerca/IllegalDateException.java @@ -1,5 +1,3 @@ -package com.gmail.zurlo.michelef.util; - public class IllegalDateException extends RuntimeException { public IllegalDateException() { diff --git a/src/CentroRicerca/IllegalPercentageException.java b/src/CentroRicerca/IllegalPercentageException.java index 0154f3c..ce071fe 100644 --- a/src/CentroRicerca/IllegalPercentageException.java +++ b/src/CentroRicerca/IllegalPercentageException.java @@ -1,5 +1,3 @@ -package com.gmail.zurlo.michelef.util; - public class IllegalPercentageException extends RuntimeException { public IllegalPercentageException() { diff --git a/src/CentroRicerca/IncorrectLabelException.java b/src/CentroRicerca/IncorrectLabelException.java index aa92996..0a19b2b 100644 --- a/src/CentroRicerca/IncorrectLabelException.java +++ b/src/CentroRicerca/IncorrectLabelException.java @@ -1,5 +1,3 @@ -package com.gmail.zurlo.michelef.util; - public class IncorrectLabelException extends RuntimeException { public IncorrectLabelException() { diff --git a/src/CentroRicerca/IndustrialProject.java b/src/CentroRicerca/IndustrialProject.java index d3aca1c..85cb4d1 100644 --- a/src/CentroRicerca/IndustrialProject.java +++ b/src/CentroRicerca/IndustrialProject.java @@ -1,11 +1,7 @@ -package com.gmail.zurlo.michelef.classi; - import java.io.PrintStream; import java.util.Date; import java.util.Scanner; -import com.gmail.zurlo.michelef.util.IllegalPercentageException; - public class IndustrialProject extends Project { public IndustrialProject(String name, String description, double budget, Date start, Date end, String company, diff --git a/src/CentroRicerca/Project.java b/src/CentroRicerca/Project.java index 5719070..3797743 100644 --- a/src/CentroRicerca/Project.java +++ b/src/CentroRicerca/Project.java @@ -1,14 +1,9 @@ -package com.gmail.zurlo.michelef.classi; - import java.io.PrintStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Scanner; -import com.gmail.zurlo.michelef.util.Constants; -import com.gmail.zurlo.michelef.util.IllegalDateException; - public class Project { public Project(String name, String description, double budget, Date start, Date end) { diff --git a/src/CentroRicerca/ProjectTester.java b/src/CentroRicerca/ProjectTester.java index 6db20ff..d359ce0 100644 --- a/src/CentroRicerca/ProjectTester.java +++ b/src/CentroRicerca/ProjectTester.java @@ -1,14 +1,7 @@ -package com.gmail.zurlo.michelef.scenari; - import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; -import com.gmail.zurlo.michelef.classi.IndustrialProject; -import com.gmail.zurlo.michelef.classi.Project; -import com.gmail.zurlo.michelef.classi.ResearchProject; -import com.gmail.zurlo.michelef.util.IncorrectLabelException; - public class ProjectTester { public static void main(String[] args) throws FileNotFoundException { diff --git a/src/CentroRicerca/ResearchCenter.java b/src/CentroRicerca/ResearchCenter.java index 6dded3f..ab36e1c 100644 --- a/src/CentroRicerca/ResearchCenter.java +++ b/src/CentroRicerca/ResearchCenter.java @@ -1,12 +1,8 @@ -package com.gmail.zurlo.michelef.classi; - import java.io.PrintStream; import java.util.ArrayList; import java.util.Date; import java.util.Scanner; -import com.gmail.zurlo.michelef.util.IncorrectLabelException; - public class ResearchCenter { public ResearchCenter(Scanner sc) { @@ -86,6 +82,16 @@ public class ResearchCenter { 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; diff --git a/src/CentroRicerca/ResearchCenterTester.java b/src/CentroRicerca/ResearchCenterTester.java index 405b529..f10dc50 100644 --- a/src/CentroRicerca/ResearchCenterTester.java +++ b/src/CentroRicerca/ResearchCenterTester.java @@ -1,11 +1,7 @@ -package com.gmail.zurlo.michelef.scenari; - import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; -import com.gmail.zurlo.michelef.classi.ResearchCenter; - public class ResearchCenterTester { public static void main(String[] args) throws FileNotFoundException { diff --git a/src/CentroRicerca/ResearchProject.java b/src/CentroRicerca/ResearchProject.java index aef3d93..0f8dfce 100644 --- a/src/CentroRicerca/ResearchProject.java +++ b/src/CentroRicerca/ResearchProject.java @@ -1,3 +1,61 @@ +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; @@ -57,4 +115,4 @@ public class ResearchProject extends Project { private String fundingBody; private String fundingLaw; -} +} \ No newline at end of file