Otros
This commit is contained in:
3
.idea/dictionaries/h4ckx0r.xml
generated
Normal file
3
.idea/dictionaries/h4ckx0r.xml
generated
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="h4ckx0r" />
|
||||||
|
</component>
|
||||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="JavadocGenerationManager">
|
<component name="JavadocGenerationManager">
|
||||||
|
|||||||
21
src/otros/arkanoid/Juego.java
Normal file
21
src/otros/arkanoid/Juego.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package otros.arkanoid;
|
||||||
|
|
||||||
|
import capitulo04.utils.Utils;
|
||||||
|
|
||||||
|
public class Juego {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Ladrillo[] ladrillos = new Ladrillo[20];
|
||||||
|
Pelota pelota = new Pelota();
|
||||||
|
|
||||||
|
for (int i = 0; i < ladrillos.length; i++) {
|
||||||
|
ladrillos[i] = new Ladrillo();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
pelota.setX(Utils.generarIntAleatorioEntreLimites(0,800));
|
||||||
|
pelota.setY(Utils.generarIntAleatorioEntreLimites(0,800));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
103
src/otros/arkanoid/Ladrillo.java
Normal file
103
src/otros/arkanoid/Ladrillo.java
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
package otros.arkanoid;
|
||||||
|
|
||||||
|
import capitulo04.utils.Utils;
|
||||||
|
|
||||||
|
public class Ladrillo {
|
||||||
|
private String color;
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int ancho;
|
||||||
|
private int alto;
|
||||||
|
private int puntosVida;
|
||||||
|
|
||||||
|
public Ladrillo() {
|
||||||
|
this.x = Utils.generarIntAleatorioEntreLimites(0, 800);
|
||||||
|
this.y = Utils.generarIntAleatorioEntreLimites(0, 500);
|
||||||
|
this.ancho = 100;
|
||||||
|
this.alto = 50;
|
||||||
|
this.puntosVida = Utils.generarIntAleatorioEntreLimites(1, 3);
|
||||||
|
|
||||||
|
String[] colores = new String[]{"rojo", "verde", "azul"};
|
||||||
|
if (puntosVida == 1) {
|
||||||
|
int colorEscogido = Utils.generarIntAleatorioEntreLimites(0, 2);
|
||||||
|
this.color = colores[colorEscogido];
|
||||||
|
} else if (puntosVida == 2) {
|
||||||
|
this.color = "plateado";
|
||||||
|
} else {
|
||||||
|
this.color = "dorado";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p Pelota
|
||||||
|
* @return Devuelve si tiene vida o se ha quedado a 0
|
||||||
|
*/
|
||||||
|
public boolean pelotaChocaEnLadrillo(Pelota p) {
|
||||||
|
if (p.getX() > this.x
|
||||||
|
&& p.getY() > this.y) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(String color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(int x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(int y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAncho() {
|
||||||
|
return ancho;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAncho(int ancho) {
|
||||||
|
this.ancho = ancho;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAlto() {
|
||||||
|
return alto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlto(int alto) {
|
||||||
|
this.alto = alto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPuntosVida() {
|
||||||
|
return puntosVida;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPuntosVida(int puntosVida) {
|
||||||
|
this.puntosVida = puntosVida;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Ladrillo{" +
|
||||||
|
"color='" + color + '\'' +
|
||||||
|
", x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", ancho=" + ancho +
|
||||||
|
", alto=" + alto +
|
||||||
|
", puntosVida=" + puntosVida +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/otros/arkanoid/Pelota.java
Normal file
33
src/otros/arkanoid/Pelota.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package otros.arkanoid;
|
||||||
|
|
||||||
|
public class Pelota {
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
|
||||||
|
public Pelota() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(int x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(int y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Pelota{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/otros/cromos/Cromo.java
Normal file
49
src/otros/cromos/Cromo.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package otros.cromos;
|
||||||
|
|
||||||
|
public class Cromo {
|
||||||
|
private String nombreJugador;
|
||||||
|
private int puntuacion;
|
||||||
|
private String equipo;
|
||||||
|
|
||||||
|
public Cromo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cromo(String nombreJugador, int puntuacion, String equipo) {
|
||||||
|
this.nombreJugador = nombreJugador;
|
||||||
|
this.puntuacion = puntuacion;
|
||||||
|
this.equipo = equipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombreJugador() {
|
||||||
|
return nombreJugador;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombreJugador(String nombreJugador) {
|
||||||
|
this.nombreJugador = nombreJugador;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getPuntuacion() {
|
||||||
|
return puntuacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPuntuacion(int puntuacion) {
|
||||||
|
this.puntuacion = puntuacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEquipo() {
|
||||||
|
return equipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEquipo(String equipo) {
|
||||||
|
this.equipo = equipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Cromo{" +
|
||||||
|
"nombre='" + nombreJugador + '\'' +
|
||||||
|
", puntuacion=" + puntuacion +
|
||||||
|
", equipo='" + equipo + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/otros/cromos/CromoBaloncesto.java
Normal file
31
src/otros/cromos/CromoBaloncesto.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package otros.cromos;
|
||||||
|
|
||||||
|
public class CromoBaloncesto extends Cromo{
|
||||||
|
private int altura;
|
||||||
|
|
||||||
|
public CromoBaloncesto() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CromoBaloncesto(String nombreJugador, int puntuacion, String equipo) {
|
||||||
|
super(nombreJugador, puntuacion, equipo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CromoBaloncesto(String nombreJugador, int puntuacion, String equipo, int altura) {
|
||||||
|
super(nombreJugador, puntuacion, equipo);
|
||||||
|
this.altura = altura;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAltura() {
|
||||||
|
return altura;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAltura(int altura) {
|
||||||
|
this.altura = altura;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void prueba() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
10
src/otros/cromos/CromoFutbol.java
Normal file
10
src/otros/cromos/CromoFutbol.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package otros.cromos;
|
||||||
|
|
||||||
|
public class CromoFutbol extends Cromo{
|
||||||
|
public CromoFutbol() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CromoFutbol(String nombreJugador, int puntuacion, String equipo) {
|
||||||
|
super(nombreJugador, puntuacion, equipo);
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/otros/cromos/Principal.java
Normal file
9
src/otros/cromos/Principal.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package otros.cromos;
|
||||||
|
|
||||||
|
public class Principal {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
CromoBaloncesto pepe = new CromoBaloncesto("Hola", 70, "pepe");
|
||||||
|
//System.out.println(pepe/*.getPuntuacion()*/);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user