Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Repo #9

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<accessrules>
<accessrule kind="accessible" pattern="javafx/**"/>
</accessrules>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added ChipsChallengeFirstDeliverable.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ChipsChallengeRoughClassDiagram.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions src/ColumbusGame/OceanExplorer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ColumbusGame;

public class OceanExplorer {

}
22 changes: 17 additions & 5 deletions src/edu/nd/sarec/railwaycrossing/Simulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import edu.nd.sarec.railwaycrossing.model.infrastructure.gate.CrossingGate;
import edu.nd.sarec.railwaycrossing.model.vehicles.Car;
import edu.nd.sarec.railwaycrossing.model.vehicles.Train;
import edu.nd.sarec.railwaycrossing.model.vehicles.Train2;
import edu.nd.sarec.railwaycrossing.view.MapDisplay;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
Expand Down Expand Up @@ -42,26 +43,37 @@ public void start(Stage stage) throws Exception {

// Train
RailwayTracks track = mapBuilder.getTrack("Royal");
RailwayTracks track2 = mapBuilder.getTrack2("Gold");
Train train = new Train(track.getEndX()+100,track.getEndY()-25);
Train2 train2 = new Train2(track2.getStartX()-100,track2.getEndY()-25);
root.getChildren().add(train.getImageView());

for(CrossingGate gate: mapBuilder.getAllGates())
train.addObserver(gate);

root.getChildren().add(train2.getImageView());
//for(CrossingGate gate: mapBuilder.getAllGates())
//train.addObserver(gate);
//for(CrossingGate gate: mapBuilder.getAllGates())
//train2.addObserver(gate);
train.addObserver(mapBuilder.setGate("Gate1"));
train.addObserver(mapBuilder.setGate("Gate2"));
train2.addObserver(mapBuilder.setGate("Gate3"));
train2.addObserver(mapBuilder.setGate("Gate4"));
// Sets up a repetitive loop i.e., in handle that runs the actual simulation
new AnimationTimer(){

@Override
public void handle(long now) {

createCar();
train.move();
train.moveWest();
train2.moveEast();

for(CrossingGate gate: mapBuilder.getAllGates())
gate.operateGate();

if (train.offScreen())
train.reset();

if (train2.offScreen())
train2.reset();

clearCars();
}
Expand Down
Binary file not shown.
Binary file not shown.
148 changes: 148 additions & 0 deletions src/edu/nd/sarec/railwaycrossing/model/infrastructure/ArraryList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package edu.nd.sarec.railwaycrossing.model.infrastructure;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class ArraryList<T> implements List<RailwayTracks> {

@Override
public boolean add(RailwayTracks e) {
// TODO Auto-generated method stub
return false;
}

@Override
public void add(int index, RailwayTracks element) {
// TODO Auto-generated method stub

}

@Override
public boolean addAll(Collection<? extends RailwayTracks> c) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean addAll(int index, Collection<? extends RailwayTracks> c) {
// TODO Auto-generated method stub
return false;
}

@Override
public void clear() {
// TODO Auto-generated method stub

}

@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean containsAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}

@Override
public RailwayTracks get(int index) {
// TODO Auto-generated method stub
return null;
}

@Override
public int indexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}

@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}

@Override
public Iterator<RailwayTracks> iterator() {
// TODO Auto-generated method stub
return null;
}

@Override
public int lastIndexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}

@Override
public ListIterator<RailwayTracks> listIterator() {
// TODO Auto-generated method stub
return null;
}

@Override
public ListIterator<RailwayTracks> listIterator(int index) {
// TODO Auto-generated method stub
return null;
}

@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}

@Override
public RailwayTracks remove(int index) {
// TODO Auto-generated method stub
return null;
}

@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}

@Override
public RailwayTracks set(int index, RailwayTracks element) {
// TODO Auto-generated method stub
return null;
}

@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}

@Override
public List<RailwayTracks> subList(int fromIndex, int toIndex) {
// TODO Auto-generated method stub
return null;
}

@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return null;
}

@Override
public <T> T[] toArray(T[] a) {
// TODO Auto-generated method stub
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,30 @@ public MapBuilder(){
private void buildRoads(){
roads.put("Western Highway",new Road(new Point(800,0),new Point (800,1000),Direction.SOUTH,true,false));
roads.put("Skyway",new Road(new Point(400,0),new Point (400,1000),Direction.SOUTH,true,false));
roads.put("EastWest",new Road(new Point(415,800),new Point (785,800),Direction.EAST,true,true));
roads.put("EastWest",new Road(new Point(415,620),new Point (785,620),Direction.EAST,true,true));
}

public CrossingGate setGate(String gate) {
return gates.get(gate);
}

private void buildCrossingGates(){
gates.put("Gate1", new CrossingGate(780,480, "Gate1"));
gates.put("Gate2", new CrossingGate(380,480, "Gate2"));
gates.put("Gate1", new CrossingGate(780,280, "Gate1"));
gates.put("Gate2", new CrossingGate(380,280, "Gate2"));
gates.put("Gate3", new CrossingGate(780,510, "Gate3"));
gates.put("Gate4", new CrossingGate(380,510, "Gate4"));
}

private void buildTracks(){
tracks.put("Royal", new RailwayTracks(new Point(0,500),new Point(1200,500)));
tracks.put("Royal", new RailwayTracks(new Point(0,300),new Point(1200,300)));
tracks.put("Gold", new RailwayTracks(new Point(0,530),new Point(1200,530)));
}

private void assignGatesToRoads(){
roads.get("Western Highway").assignGate(gates.get("Gate1"));
roads.get("Skyway").assignGate(gates.get("Gate2"));
roads.get("Western Highway").assignGate(gates.get("Gate3"));
roads.get("Skyway").assignGate(gates.get("Gate4"));
}

private void buildCarFactories(){
Expand All @@ -67,4 +76,8 @@ public Collection<Road> getRoads(){
public RailwayTracks getTrack(String name){
return tracks.get("Royal");
}

public RailwayTracks getTrack2(String name){
return tracks.get("Gold");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Observer;

import edu.nd.sarec.railwaycrossing.model.vehicles.Train;
import edu.nd.sarec.railwaycrossing.model.vehicles.Train2;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
Expand All @@ -21,7 +22,9 @@ public class CrossingGate extends Observable implements Observer{
private int movingX;
private int movingY;
private int triggerPoint;
private int triggerPoint2;
private int exitPoint;
private int exitPoint2;

private IGateState gateClosed;
private IGateState gateOpen;
Expand All @@ -41,7 +44,9 @@ public CrossingGate(int xPosition, int yPosition, String crossingGate){
movingX = anchorX;
movingY = anchorY-60;
triggerPoint = anchorX+250;
triggerPoint2 = anchorX-250;
exitPoint = anchorX-250;
exitPoint2 = anchorX+250;

// Gate elements
line = new Line(anchorX, anchorY,movingX,movingY);
Expand Down Expand Up @@ -111,6 +116,10 @@ public void setGateState(IGateState newState){
notifyObservers();
}

public int getAnchorY() {
return anchorY;
}

public String getTrafficCommand(){
return currentGateState.getTrafficAction();
}
Expand All @@ -125,5 +134,13 @@ else if(train.getVehicleX() < triggerPoint){
currentGateState.approachStation();
}
}
if (o instanceof Train2){
Train2 train2 = (Train2)o;
if (train2.getVehicleX() > exitPoint2)
currentGateState.leaveStation();
else if(train2.getVehicleX() > triggerPoint2){
currentGateState.approachStation();
}
}
}
}
Loading