diff --git a/src/main/java/br/utfpr/tdd/ex1/Aluno.java b/src/main/java/br/utfpr/tdd/ex1/Aluno.java index 63588d7..3bd1930 100644 --- a/src/main/java/br/utfpr/tdd/ex1/Aluno.java +++ b/src/main/java/br/utfpr/tdd/ex1/Aluno.java @@ -44,8 +44,9 @@ void setNotaProjeto(double nota) { double getNF() { if(notaRAA < 0) return (notaProjeto + getNAP()) / 2.0; - - return (notaProjeto + getNAP() + notaRAA) / 3.0; + + double NF = (notaProjeto + getNAP() + notaRAA) / 3.0 ; + return NF > 6 ? 6 : NF; } void setNotaRAA(double nota) { diff --git a/src/main/java/br/utfpr/tdd/ex1/EscritorCSV.java b/src/main/java/br/utfpr/tdd/ex1/EscritorCSV.java index 6aec7ca..fac93fe 100644 --- a/src/main/java/br/utfpr/tdd/ex1/EscritorCSV.java +++ b/src/main/java/br/utfpr/tdd/ex1/EscritorCSV.java @@ -1,6 +1,7 @@ package br.utfpr.tdd.ex1; import java.io.BufferedWriter; +import java.io.IOException; import java.math.RoundingMode; import java.nio.file.Files; import java.nio.file.Paths; @@ -9,28 +10,27 @@ import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; + import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; /** - * * @author andreendo */ class EscritorCSV { CSVPrinter csvPrinter; - private final static Logger LOGGER = Logger.getLogger(EscritorCSV.class.getName()); - + private static final Logger LOGGER = Logger.getLogger(EscritorCSV.class.getName()); + void escrever(String ra, String nome, double notaFinal, String situacao) { try { - Locale locale = new Locale("en", "UK"); + Locale locale = new Locale("en", "UK"); DecimalFormat df = (DecimalFormat) - NumberFormat.getNumberInstance(locale); + NumberFormat.getNumberInstance(locale); df.applyPattern(".#"); df.setRoundingMode(RoundingMode.DOWN); csvPrinter.printRecord(ra, nome, df.format(notaFinal), situacao); - csvPrinter.flush(); - } - catch(Exception e) { + csvPrinter.flush(); + } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } @@ -40,12 +40,11 @@ void setArquivoSaida(String filePath) { BufferedWriter writer = Files.newBufferedWriter(Paths.get(filePath)); csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT - .withHeader("RA", "Nome", "NF", "Situacao")); - csvPrinter.flush(); - } - catch(Exception e) { + .withHeader("RA", "Nome", "NF", "Situacao")); + csvPrinter.flush(); + } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } - + }