Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implemented locking doors.

  • Loading branch information...
commit e4e7f2fc654dba2235889a67d064b66cafa40cda 1 parent 34f8de1
@silentdragoon authored
Showing with 88 additions and 0 deletions.
  1. +46 −0 Door.java
  2. +42 −0 Exit.java
View
46 Door.java
@@ -0,0 +1,46 @@
+
+/**
+ * Write a description of class Door here.
+ *
+ * @author (your name)
+ * @version (a version number or a date)
+ */
+public class Door extends Exit
+{
+ // instance variables - replace the example below with your own
+ private boolean locked;
+
+ /**
+ * Constructor for objects of class Door
+ */
+ public Door(String direction, Room neighbor, boolean locked)
+ {
+ // initialise instance variables
+ this.direction = direction;
+ this.neighbor = neighbor;
+ this.locked = locked;
+ }
+
+ /**
+ * An example of a method - replace this comment with your own
+ *
+ * @param y a sample parameter for a method
+ * @return the sum of x and y
+ */
+ public void lock()
+ {
+ locked = true;
+ return;
+ }
+
+ public void unlock()
+ {
+ locked = false;
+ return;
+ }
+
+ public Room getLocked()
+ {
+ return locked;
+ }
+}
View
42 Exit.java
@@ -0,0 +1,42 @@
+
+/**
+ * Write a description of class Exit here.
+ *
+ * @author (your name)
+ * @version (a version number or a date)
+ */
+public class Exit
+{
+ // instance variables - replace the example below with your own
+ private String direction;
+ private Room neighbor;
+
+ /**
+ * Constructor for objects of class Exit
+ */
+ public Exit(String direction, Room neighbor)
+ {
+ // initialise instance variables
+ this.direction = direction;
+ this.neighbor = neighbor;
+
+ }
+
+ /**
+ * An example of a method - replace this comment with your own
+ *
+ * @param y a sample parameter for a method
+ * @return the sum of x and y
+ */
+
+ public String getDirection()
+ {
+ // put your code here
+ return direction;
+ }
+
+ public Room getNeighbor()
+ {
+ return neighbor;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.