Skip to content

Commit 49edc31

Browse files
committed
Primer comit en la master
0 parents  commit 49edc31

File tree

9 files changed

+156
-0
lines changed

9 files changed

+156
-0
lines changed

cabreraalejandro_main/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>connecta4</groupId>
8+
<artifactId>cabreraalejandro_main</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>17</maven.compiler.source>
13+
<maven.compiler.target>17</maven.compiler.target>
14+
</properties>
15+
16+
</project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package connecta4;
2+
3+
public class Game {
4+
Player player1;
5+
Player player2;
6+
Table main_Table;
7+
8+
public Game(Player player1, Player player2, Table main_Table) {
9+
this.player1 = player1;
10+
this.player2 = player2;
11+
this.main_Table = main_Table;
12+
}
13+
14+
public Player getPlayer1() {
15+
return player1;
16+
}
17+
18+
public void setPlayer1(Player player1) {
19+
this.player1 = player1;
20+
}
21+
22+
public Player getPlayer2() {
23+
return player2;
24+
}
25+
26+
public void setPlayer2(Player player2) {
27+
this.player2 = player2;
28+
}
29+
30+
public Table getMain_Table() {
31+
return main_Table;
32+
}
33+
34+
public void setMain_Table(Table main_Table) {
35+
this.main_Table = main_Table;
36+
}
37+
38+
public boolean remakeGame (String confirmation){
39+
if (confirmation.toUpperCase() == "Y") {
40+
return true;
41+
} else {
42+
return false;
43+
}
44+
}
45+
public void printTable(){
46+
for (int i = 0; i < array.length; i++) {
47+
48+
}
49+
50+
}
51+
52+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package connecta4;
2+
3+
import java.util.Scanner;
4+
5+
public class Main {
6+
public static void main(String[] args) {
7+
// Utilizem la clase Scanner per llegir l'input de l'usuari
8+
Scanner input = new Scanner(System.in);
9+
10+
11+
// Preguntem el nom dels jugador i creem nous objectes "Player".
12+
System.out.println("Introdueix el nom del jugador 1");
13+
Player player1 = new Player(input.nextLine());
14+
System.out.println("Introdueix el nom del jugador 2");
15+
Player player2 = new Player(input.nextLine());
16+
17+
// Ara crearem un nou Taulell indicant el nombre de files i columnes
18+
19+
System.out.println("Introdueix el nombre de files");
20+
Table main_Table = new Table (input.nextInt(), 1);
21+
System.out.println("Introudeix el nombre de columnes");
22+
main_Table.setColumns(input.nextInt());
23+
24+
// Amb aixó ja podem crear un objecte Game a qui li pasarem els jugadors i taulell per parametre
25+
26+
Game game1 = new Game(player1, player2, main_Table);
27+
do {
28+
29+
System.out.println("Vols tornar a jugar?");
30+
} while (game1.remakeGame(input.nextLine()));
31+
32+
}
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package connecta4;
2+
3+
public class Player {
4+
String name;
5+
int wins;
6+
7+
8+
/** Constructor de jugador
9+
* @param name
10+
*/
11+
public Player(String name) {
12+
this.name = name;
13+
wins = 0;
14+
}
15+
public String getname() {
16+
return name;
17+
}
18+
public void setname(String name) {
19+
this.name = name;
20+
}
21+
public int getWins() {
22+
return wins;
23+
}
24+
public void setWins(int wins) {
25+
this.wins = wins;
26+
}
27+
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package connecta4;
2+
3+
public class Table {
4+
int rows;
5+
int columns;
6+
7+
public Table(int rows, int columns) {
8+
this.rows = rows;
9+
this.columns = columns;
10+
}
11+
public int getRows() {
12+
return rows;
13+
}
14+
15+
public void setRows(int rows) {
16+
this.rows = rows;
17+
}
18+
19+
public int getColumns() {
20+
return columns;
21+
}
22+
23+
public void setColumns(int columns) {
24+
this.columns = columns;
25+
}
26+
27+
}
1.53 KB
Binary file not shown.
1.45 KB
Binary file not shown.
744 Bytes
Binary file not shown.
700 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)