Skip to content
Snippets Groups Projects
Select Git revision
  • d4d7fa9f46c67a78214e8dccc3accf849135e37d
  • master default protected
2 results

Grid.java

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ComputerPlayer.java 1.21 KiB
    package model;
    
    import javafx.scene.paint.Color;
    
    public class ComputerPlayer implements Player{
    
        private String name;
        private Cell cellStart;
        private PlayStrategy strategi;
        public ComputerPlayer(String name, Cell start){
            this.name=name;
            this.cellStart=start;
        }
        public ComputerPlayer(Cell start, PlayStrategy strategi){
            this.name="player";
            this.cellStart=start;
            this.strategi=strategi;
    
        }
        public ComputerPlayer(String name, Cell start,PlayStrategy strategi){
            this.name=name;
            this.cellStart=start;
            this.strategi= strategi;
        }
        @Override
        public boolean isHuman() {
            return false;
        }
    
        @Override
        public void setName(String name) {
            this.name = name;
        }
    
        @Override
        public String getName() {
            return this.name;
        }
    
        @Override
        public Cell getStartCell() {
            return this.cellStart;
        }
        public Color play(){
            return this.strategi.play(this.getStartCell());//  Color.RED;
        }
        public Color setStrategy(PlayStrategy strategy){
           this.strategi=strategy;
           return this.play();
      }
        public void setStartCell(Cell start){
            this.cellStart=start;
        }
    
    }