1
0
Fork 0

Aufgabe 3.4

master A3.1
rxbn_ 3 years ago
parent 94a394438d
commit 4bec1047ed
  1. 2
      src/break_out/Constants.java
  2. 144
      src/break_out/model/Stone.java

@ -5,7 +5,7 @@ import java.awt.Color;
/**
* A class that contains all constant values to configure the game
*
* @author dmlux, modified by I. Schumacher
* @author dmlux, modified by I. Schumacher, modified by Gruppe 175: Ruben Meyer und Moritz Henseleit
*/
public class Constants {

@ -0,0 +1,144 @@
package break_out.model;
import java.awt.*;
/**
* This class contains information about the stones characteristics and behaviour
*
* @author Gruppe 175: Moritz Henseleit, Rubn Meyer
*/
public class Stone implements IStone {
/**
* The stones type
*/
private int type;
/**
* The stones value according to the stones type to calculate players score
*/
private int value;
/**
* The stones color according to the stones type
*/
private Color color;
/**
* The stones position on the playground
*/
private Position position;
/**
* The constructor of a stone
*
* @param type stones initial type
* @param position stones initial position
*/
public Stone(int type, Position position) {
// sets type; and value and color according to stone type
setType(type);
// sets position
setPosition(position);
}
/**
* The getter for the stones value to calculate players score
*
* @return stones value
*/
public int getValue() {
return this.value;
}
/**
* The setter for the stones value
*
* @param value The stones new value
*/
public void setValue(int value) {
this.value = value;
}
/**
* The getter for the stones color
* Can be null because a stone could not exist
*
* @return The stones color
*/
public Color getColor() {
return this.color;
}
/**
* The setter for the stones color
*
* @param color The stones new color
*/
public void setColor(Color color) {
this.color = color;
}
/**
* The getter for the stones position
*
* @return The stones position
*/
public Position getPosition() {
return this.position;
}
/**
* The setter for the stones position
*
* @param position The stones new position
*/
public void setPosition(Position position) {
this.position = position;
}
/**
* The getter for the stones type
*
* @return The stones type
*/
public int getType() {
return this.type;
}
/**
* The setter for the stones type
*
* @param type The stones new type
*/
public void setType(int type) {
// type not in range
if(type > 3) { type = 0; }
setValue(type);
this.type = type;
switch(type) {
// multi-case, hacky, but dont care
case 0:
// naah, isnt a stone
default:
// default case, not in range
// setting to not a stone
setColor(null);
break;
case 1:
// stone type one
setColor(Color.CYAN);
break;
case 2:
// stone type two
setColor(Color.WHITE);
break;
case 3:
// stone type three
setColor(Color.BLUE);
break;
}
}
}
Loading…
Cancel
Save