Commit e25bedd9 authored by Yuhan Chen's avatar Yuhan Chen
Browse files

Update for demo rules and object classes

parent 01c5e231
......@@ -23,6 +23,7 @@ javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
dependencies {
implementation 'org.jetbrains:annotations:20.1.0'
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
}
application {
......
......@@ -20,19 +20,27 @@
import javafx.scene.image.Image;
public class Baba extends NameWord {
public class Baba extends NameWordImpl {
public String name = "Baba";
Image image = new Image("resources/image/baba.pgn");
private Image image = new Image("resources/image/baba.pgn");
public Baba(int x, int y) {
setCoordinate(x,y);
this.image = image;
}
@Override
public String getName() {
return name;
}
public Image addImage() {
return image;
public Image getImage() {
return this.image;
}
public boolean isPushable() {return true;}
@Override public boolean isPushable() {return true;}
}
......@@ -49,4 +49,11 @@ public abstract class ConnectorWord implements GeneralObject {
this.y += newY;
this.x += newX;
}
public void setCoordinate(int x, int y) {
this.x = x;
this.y = y;
}
public boolean isPushable() {return this.isPushable();}
}
......@@ -52,6 +52,7 @@
this.x += newX;
}
/**
* Returns the specific name of the exact type of entity. This is used when applying rules
* and movement to objects.
......
......@@ -48,11 +48,6 @@ public interface GeneralObject {
public int getX();
/**
* returns the Y coordinate location of the GeneralObject
* @returns Y integer corresponding to the object's current x coordinate
*
*/
public int getY();
/**
......@@ -62,6 +57,9 @@ public interface GeneralObject {
*/
public void move (int newX, int newY);
public default boolean isPushable() {return false;}
public void setCoordinate(int x, int y);
}
......
......@@ -20,16 +20,20 @@
import javafx.scene.image.Image;
public class Is extends ConnectorWord {
String name = "Is";
Image image = new Image("resources/image/TextIs.png");
public String name = "Is";
private Image image = new Image("resources/image/TextIs.png");
public Is(int x, int y) {
setCoordinate(x,y);
}
@Override
public String getConnector() {
return name;
}
public Image addImage() {
return image;
public Image getImage() {
return this.image;
}
public boolean isPushable() {return true;}
......
......@@ -34,7 +34,7 @@ public abstract class NameWord implements GeneralObject {
private String color;
//returns the corresponding entity name to the word (SHOULD MATCH IDENTICAL ENTITY VERSION)
abstract public String getName();
public abstract String getName();
@Override
public String getType() { return "NameWord"; }
......@@ -53,4 +53,10 @@ public abstract class NameWord implements GeneralObject {
this.y += newY;
this.x += newX;
}
@Override
public void setCoordinate(int x, int y) {
this.x = x;
this.y = y;
}
}
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2021
* Instructor: Prof. Chris Dancy
*
* Name: Yuhan Chen
* Section: YOUR SECTION
* Date: 5/15/2021
* Time: 11:39 PM
*
* Project: CSCI205SP21finalproject
* Package: PACKAGE_NAME
* Class: NameWordImpl
*
* Description: The implement class of NameWord to generate a specific NameWord object
*
* ****************************************
*/
public class NameWordImpl extends NameWord {
//coordinates
private int x;
private int y;
@Override
public boolean isPushable() {
return super.isPushable();
}
@Override
public String getName() {
return null;
}
@Override
public String getType() { return "NameWord"; }
}
\ No newline at end of file
......@@ -19,17 +19,22 @@
import javafx.scene.image.Image;
public class Rock extends NameWord {
public class Rock extends NameWordImpl {
public String name = "Rock";
Image image = new Image("resources/image/Rock.png");
private Image image = new Image("resources/image/Rock.png");
public Rock(int x, int y) {
setCoordinate(x,y);
this.image = image;
}
@Override
public String getName() {
return name;
}
public Image addImage() {
return image;
public Image getImage() {
return this.image;
}
public boolean isPushable() {return true;}
......
......@@ -49,4 +49,10 @@ public abstract class RuleWord implements GeneralObject {
this.y += newY;
this.x += newX;
}
@Override
public void setCoordinate(int x, int y) {
this.x = x;
this.y = y;
}
}
......@@ -22,6 +22,11 @@ import javafx.scene.image.Image;
public class Win extends RuleWord{
public String name = "Win";
Image image = new Image("resources/image/TextWin.png");
public Win(int x, int y) {
setCoordinate(x,y);
this.image = image;
}
@Override
public String getRule() {
return name;
......
......@@ -25,7 +25,6 @@ public class LevelMenuMain extends Application {
@Override
public void start(Stage primaryStage) {
Scene scene = new Scene(theView.getRoot());
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.setTitle("Baba is Us");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment