Skip to content

Commit f3a538d

Browse files
authored
Add files via upload
1 parent 24e6357 commit f3a538d

16 files changed

Lines changed: 202 additions & 50 deletions

File tree

Campeonato/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
<artifactId>maven-compiler-plugin</artifactId>
8686
<version>3.1</version>
8787
<configuration>
88-
<source>1.7</source>
89-
<target>1.7</target>
88+
<source>1.8</source>
89+
<target>1.8</target>
9090
<compilerArguments>
9191
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
9292
</compilerArguments>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package model;
7+
8+
import java.io.BufferedReader;
9+
import java.io.FileReader;
10+
import java.io.IOException;
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
/**
15+
*
16+
* @author deinfo
17+
*/
18+
public class Dados {
19+
private BufferedReader br = null;
20+
private String nomeArq;
21+
private Jogo jgLinha;
22+
23+
List<Time> lstTimes = new ArrayList<>();
24+
25+
public Dados (String nomeArq) {
26+
this.nomeArq = nomeArq;
27+
}
28+
29+
private Time achaTime (String nomeBusca) {
30+
for (Time t : lstTimes) {
31+
if (t.getNome().equals(nomeBusca)) {
32+
return t;
33+
}
34+
}
35+
Time novoTime = new Time();
36+
return novoTime;
37+
}
38+
39+
private void analisa (Jogo jg) {
40+
Time posTimeA, posTimeB;
41+
42+
posTimeA = achaTime(jg.getTimeA());
43+
posTimeB = achaTime(jg.getTimeB());
44+
45+
}
46+
47+
public List<Time> ler() {
48+
String linha;
49+
try {
50+
br = new BufferedReader (new FileReader(nomeArq));
51+
while ((linha = br.readLine()) != null) {
52+
jgLinha = new Jogo(linha);
53+
}
54+
} catch (Exception e) {
55+
56+
} finally {
57+
try {
58+
if (br != null) {
59+
br.close();
60+
}
61+
} catch (IOException ex) {
62+
63+
}
64+
}
65+
66+
return lstTimes;
67+
}
68+
}

Campeonato/src/main/java/model/Jogo.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ public Jogo() {
4949

5050
}
5151

52+
public Jogo(String linha) {
53+
String[] partes = linha.split("\\,");
54+
55+
this.timeA = partes[0];
56+
this.golA = Byte.parseByte(partes[1]);
57+
this.timeB = partes[2];
58+
this.golB = Byte.parseByte(partes[3]);
59+
}
60+
61+
public Jogo(String timeA, String timeB, byte golA, byte golB) {
62+
this.timeA = timeA;
63+
this.timeB = timeB;
64+
this.golA = golA;
65+
this.golB = golB;
66+
}
67+
5268
public Jogo(String timeA, String golA, String timeB, String golB) {
5369
this.timeA = timeA.toUpperCase();
5470
this.timeB = timeB.toUpperCase();

Campeonato/src/main/java/model/Time.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*/
1212
public class Time {
1313
String nome;
14-
int vit = 0, der = 0, emp = 0;
15-
int golP = 0, golN = 0;
14+
Integer vit = 0, der = 0, emp = 0;
15+
Integer golP = 0, golN = 0;
1616

1717
public String getNome() {
1818
return nome;
@@ -90,6 +90,14 @@ void addEmp() {
9090
void addDer() {
9191
this.der++;
9292
}
93+
94+
void addGolP(byte gols) {
95+
this.golP += gols;
96+
}
97+
98+
void addGolN(byte gols) {
99+
this.golN += gols;
100+
}
93101

94102
public Time() {
95103
}
Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,59 @@
11
package view;
22

33
import java.net.URL;
4+
import java.util.ArrayList;
5+
import java.util.List;
46
import java.util.ResourceBundle;
57
import javafx.event.ActionEvent;
68
import javafx.fxml.FXML;
79
import javafx.fxml.Initializable;
8-
import javafx.scene.control.Label;
10+
import javafx.scene.control.TableColumn;
11+
import javafx.scene.control.TableView;
12+
import model.Dados;
913
import model.Jogo;
1014
import model.Time;
1115

1216
public class PrincipalController implements Initializable {
1317

14-
@FXML
15-
private Label label;
18+
private Dados dados;
19+
private List<Time> lstPrinc = new ArrayList<Time> ();
20+
21+
@FXML private TableView<Jogo> tblVwCmp;
22+
@FXML private TableColumn<Jogo, String> tblClmnTime;
23+
@FXML private TableColumn<Jogo, Integer> tblClmnP, tblClmnV, tblClmnD, tblClmnE, tblClmnGP, tblClmnGC, tblClmnSD;
1624

1725
@FXML
18-
private void handleButtonAction(ActionEvent event) {
19-
System.out.println("You clicked me!");
20-
label.setText("Hello World!");
26+
private void btnImportarClick(ActionEvent event) {
27+
/*try {
28+
List<Jogo> lstJogo = new ArrayList<Jogo>();
29+
30+
FileReader arq = new FileReader("F:\\jogo.txt");
31+
BufferedReader lerarq = new BufferedReader(arq);
32+
33+
String partida[] = new String[4];
34+
String linha = lerarq.readLine();
35+
36+
partida = linha.split(",");
37+
while (linha != null) {
38+
partida = linha.split(",");
39+
lstJogo.add(new Jogo(partida[0], partida[1], partida[2], partida[3]));
40+
linha = lerarq.readLine();
41+
}
42+
} catch (IOException e) {
43+
System.err.printf("Erro na abertura do arquivo: %s.\n", e.getMessage());
44+
}
45+
46+
for (Jogo j : lstJogo) {
47+
System.out.println("NomeTime1: " + j.getTimeA() + " GolsTimeA: " + j.getGolA() + " NomeTimeB: " + j.getTimeB() + " GolsTimeB: " + j.getGolB());
48+
//tblClmnTime.setCellValueFactory();
49+
}*/
2150
}
2251

2352
@Override
2453
public void initialize(URL url, ResourceBundle rb) {
25-
// TODO
54+
// TODO
55+
dados = new Dados("G:\\jogo.txt");
2656

27-
Time time1 = new Time("Curintia");
28-
Time time2 = new Time("Framenguis");
29-
30-
Jogo jogo1 = new Jogo(time1.getNome(), "3", time2.getNome(), "2");
31-
System.out.println("NomeTime1: " + jogo1.getTimeA() + " GolsTimeA: " + jogo1.getGolA() + " NomeTimeB: " + jogo1.getTimeB() + " GolsTimeB: " + jogo1.getGolB());
57+
lstPrinc = dados.ler();
3258
}
3359
}
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<?import java.lang.*?>
4-
<?import java.util.*?>
5-
<?import javafx.scene.*?>
6-
<?import javafx.scene.control.*?>
7-
<?import javafx.scene.layout.*?>
8-
9-
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="view.PrincipalController">
10-
<children>
11-
<Button layoutX="126" layoutY="90" text="Click Me!" onAction="#handleButtonAction" fx:id="button" />
12-
<Label layoutX="126" layoutY="120" minHeight="16" minWidth="69" fx:id="label" />
13-
</children>
14-
</AnchorPane>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.scene.*?>
6+
<?import javafx.scene.control.*?>
7+
<?import javafx.scene.layout.*?>
8+
9+
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="view.PrincipalController">
10+
<children>
11+
<VBox layoutX="104.0" layoutY="-22.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
12+
<children>
13+
<Button mnemonicParsing="false" onAction="#btnImportarClick" text="Importar" />
14+
<TableView fx:id="tblVwCmp">
15+
<columns>
16+
<TableColumn fx:id="tblClmnClss" prefWidth="76.0" text="Classificação" />
17+
<TableColumn fx:id="tblClmnTime" prefWidth="87.0" text="Time" />
18+
<TableColumn fx:id="tblClmnP" prefWidth="64.0" text="Pontuação" />
19+
<TableColumn fx:id="tblClmnV" prefWidth="50.0" text="Vitórias" />
20+
<TableColumn fx:id="tblClmnD" prefWidth="54.0" text="Derrotas" />
21+
<TableColumn fx:id="tblClmnE" prefWidth="52.0" text="Empates" />
22+
<TableColumn fx:id="tblClmnGP" prefWidth="52.0" text="Gols Pró" />
23+
<TableColumn fx:id="tblClmnGC" prefWidth="72.0" text="Gols Contra" />
24+
<TableColumn fx:id="tblClmnSD" prefWidth="92.0" text="Saldo de Gols" />
25+
</columns>
26+
</TableView>
27+
</children>
28+
</VBox>
29+
</children>
30+
</AnchorPane>
1.64 KB
Binary file not shown.
0 Bytes
Binary file not shown.
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<?import java.lang.*?>
4-
<?import java.util.*?>
5-
<?import javafx.scene.*?>
6-
<?import javafx.scene.control.*?>
7-
<?import javafx.scene.layout.*?>
8-
9-
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="view.PrincipalController">
10-
<children>
11-
<Button layoutX="126" layoutY="90" text="Click Me!" onAction="#handleButtonAction" fx:id="button" />
12-
<Label layoutX="126" layoutY="120" minHeight="16" minWidth="69" fx:id="label" />
13-
</children>
14-
</AnchorPane>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.scene.*?>
6+
<?import javafx.scene.control.*?>
7+
<?import javafx.scene.layout.*?>
8+
9+
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="view.PrincipalController">
10+
<children>
11+
<VBox layoutX="104.0" layoutY="-22.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
12+
<children>
13+
<Button mnemonicParsing="false" onAction="#btnImportarClick" text="Importar" />
14+
<TableView fx:id="tblVwCmp">
15+
<columns>
16+
<TableColumn fx:id="tblClmnClss" prefWidth="76.0" text="Classificação" />
17+
<TableColumn fx:id="tblClmnTime" prefWidth="87.0" text="Time" />
18+
<TableColumn fx:id="tblClmnP" prefWidth="64.0" text="Pontuação" />
19+
<TableColumn fx:id="tblClmnV" prefWidth="50.0" text="Vitórias" />
20+
<TableColumn fx:id="tblClmnD" prefWidth="54.0" text="Derrotas" />
21+
<TableColumn fx:id="tblClmnE" prefWidth="52.0" text="Empates" />
22+
<TableColumn fx:id="tblClmnGP" prefWidth="52.0" text="Gols Pró" />
23+
<TableColumn fx:id="tblClmnGC" prefWidth="72.0" text="Gols Contra" />
24+
<TableColumn fx:id="tblClmnSD" prefWidth="92.0" text="Saldo de Gols" />
25+
</columns>
26+
</TableView>
27+
</children>
28+
</VBox>
29+
</children>
30+
</AnchorPane>
2.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)