daily pastebin goal
19%
SHARE
TWEET

Abstract

a guest Feb 13th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package uni.fmi.bachelor;
  2.  
  3. abstract public class Piece {
  4.     private String color;
  5.     private int points;
  6.     private String name;
  7.    
  8.     abstract public String move();
  9.     abstract public String attack();
  10.    
  11.     public Piece(String name,String color) {
  12.         this.name = name;
  13.         this.color = color;
  14.     }
  15.    
  16.    
  17.    
  18.    
  19.     public String getColor() {
  20.         return color;
  21.     }
  22.     public void setColor(String color) {
  23.         this.color = color;
  24.     }
  25.     public int getPoints() {
  26.         return points;
  27.     }
  28.     public void setPoints(int points) {
  29.         this.points = points;
  30.     }
  31.     public String getName() {
  32.         return name;
  33.     }
  34.     public void setName(String name) {
  35.         this.name = name;
  36.     }
  37.    
  38.    
  39. }
  40. ================================================
  41. package uni.fmi.bachelor;
  42.  
  43. import java.util.ArrayList;
  44.  
  45. public class MainClass {
  46.  
  47.     public static void main(String[] args) {
  48.         Pawn p = new Pawn("Pawn","White");
  49.         Knight k = new Knight("Knight","White");
  50.         Queen q = new Queen("Queen","White");
  51.        
  52.         ArrayList<Piece> pieces = new ArrayList<>();
  53.        
  54.         pieces.add(p);
  55.         pieces.add(k);
  56.         pieces.add(q);
  57.        
  58.         for(Piece pi : pieces) {
  59.             System.out.println(pi.move());
  60.             System.out.println(pi.attack());
  61.         }
  62.        
  63.  
  64.     }
  65.  
  66. }
  67. ====================================================
  68. package uni.fmi.bachelor;
  69.  
  70. public class Pawn extends Piece{
  71.  
  72.     public Pawn(String name, String color) {
  73.         super(name, color);
  74.     }
  75.  
  76.     @Override
  77.     public String move() {
  78.         return "1 Step Forrward";
  79.     }
  80.  
  81.     @Override
  82.     public String attack() {
  83.         return "1 Step Left or Right Front Diagonal";
  84.     }
  85.    
  86. }
  87. ===================================================
  88. package uni.fmi.bachelor;
  89.  
  90. public class Knight extends Piece {
  91.  
  92.     public Knight(String name, String color) {
  93.         super(name, color);
  94.     }
  95.  
  96.     @Override
  97.     public String move() {
  98.         return "L shape";
  99.     }
  100.  
  101.     @Override
  102.     public String attack() {
  103.         return "Attack in " + move();
  104.     }
  105.  
  106. }
  107. ======================================================
  108. package uni.fmi.bachelor;
  109.  
  110. public class Queen extends Piece {
  111.  
  112.     public Queen(String name, String color) {
  113.         super(name, color);
  114.     }
  115.  
  116.     @Override
  117.     public String move() {
  118.         return "Everyway";
  119.     }
  120.  
  121.     @Override
  122.     public String attack() {
  123.         return "Attack " + move();
  124.     }
  125.  
  126. }
  127. =====================================================
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top