Alexander Hartung
3 years ago
3 changed files with 71 additions and 27 deletions
-
49src/main/java/solitaer/BaseStack.java
-
20src/main/java/solitaer/MyMouseListener.java
-
27src/main/java/solitaer/StartStack.java
@ -0,0 +1,49 @@ |
|||||
|
package solitaer; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
|
||||
|
import javax.swing.JPanel; |
||||
|
|
||||
|
public abstract class BaseStack extends JPanel { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
private ArrayList<Card> stack = new ArrayList<Card>(); |
||||
|
private final int OFFSET_VALUE = 20; |
||||
|
int offset; |
||||
|
|
||||
|
public BaseStack() { |
||||
|
// TODO Auto-generated constructor stub |
||||
|
offset = 0; |
||||
|
} |
||||
|
|
||||
|
public boolean stackIsEmpty() { |
||||
|
return stack.isEmpty(); |
||||
|
} |
||||
|
|
||||
|
public void addCard(Card _card) { |
||||
|
_card.setLocation(0, offset); |
||||
|
stack.add(_card); |
||||
|
RenderStackNew(); |
||||
|
offset += OFFSET_VALUE; |
||||
|
} |
||||
|
|
||||
|
private void RenderStackNew() { |
||||
|
this.removeAll(); |
||||
|
// Alles neu Zeichnen |
||||
|
for (int i = stack.size() - 1; i >= 0; i--) { |
||||
|
this.add(stack.get(i)); |
||||
|
} |
||||
|
this.repaint(); |
||||
|
} |
||||
|
|
||||
|
public Card removeLastCard() { |
||||
|
if (stack.size() != 0) { |
||||
|
Card LastCard = stack.remove(stack.size() - 1); |
||||
|
RenderStackNew(); |
||||
|
return LastCard; |
||||
|
} |
||||
|
return null; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected abstract boolean cardCheck(Card _topStack, Card _playerCard); |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue