From e9820ebfd2d0d21f78b9dba2120b122e4aa68f80 Mon Sep 17 00:00:00 2001 From: "Loch Christian (uib05376)" Date: Wed, 16 Sep 2020 14:20:51 +0200 Subject: [PATCH] Create classes Track, Vehicle and VehicleTimeRecord. Adjust class diagram. --- .../main/java/de/hems/trafficsim/Track.java | 16 ++++++ .../main/java/de/hems/trafficsim/Vehicle.java | 35 +++++++++++++ .../de/hems/trafficsim/VehicleTimeRecord.java | 25 ++++++++++ doc/classdiagram.graphml | 49 ++++++++++++------- 4 files changed, 106 insertions(+), 19 deletions(-) create mode 100644 app/src/main/java/de/hems/trafficsim/Track.java create mode 100644 app/src/main/java/de/hems/trafficsim/Vehicle.java create mode 100644 app/src/main/java/de/hems/trafficsim/VehicleTimeRecord.java diff --git a/app/src/main/java/de/hems/trafficsim/Track.java b/app/src/main/java/de/hems/trafficsim/Track.java new file mode 100644 index 0000000..d08685b --- /dev/null +++ b/app/src/main/java/de/hems/trafficsim/Track.java @@ -0,0 +1,16 @@ +package de.hems.trafficsim; + +import java.util.LinkedList; +import java.util.List; + +public class Track { + protected List vehicles; + + public Track() { + this.vehicles = new LinkedList<>(); + } + + public void timeElapse(float timeStep) { + + } +} diff --git a/app/src/main/java/de/hems/trafficsim/Vehicle.java b/app/src/main/java/de/hems/trafficsim/Vehicle.java new file mode 100644 index 0000000..b316f42 --- /dev/null +++ b/app/src/main/java/de/hems/trafficsim/Vehicle.java @@ -0,0 +1,35 @@ +package de.hems.trafficsim; + +public class Vehicle { + protected float position; + protected float curVelocity; + protected float maxVelocity; + + public void setForerunner(Vehicle forerunner) { + this.forerunner = forerunner; + } + + protected Vehicle forerunner; + + public float getPosition() { + return position; + } + + public float getCurVelocity() { + return curVelocity; + } + + protected float brakeProp; + + public Vehicle(float position, float maxVelocity, float brakeProp) { + this.position = position; + this.maxVelocity = maxVelocity; + this.brakeProp = brakeProp; + this.curVelocity = 0; + this.forerunner = null; + } + + public void timeElapse(float timeStep) { + + } +} diff --git a/app/src/main/java/de/hems/trafficsim/VehicleTimeRecord.java b/app/src/main/java/de/hems/trafficsim/VehicleTimeRecord.java new file mode 100644 index 0000000..c3ae160 --- /dev/null +++ b/app/src/main/java/de/hems/trafficsim/VehicleTimeRecord.java @@ -0,0 +1,25 @@ +package de.hems.trafficsim; + +public class VehicleTimeRecord { + public float getPosition() { + return position; + } + + public float getVelocity() { + return velocity; + } + + public float getTimestep() { + return timestep; + } + + protected float position; + protected float velocity; + protected float timestep; + + public VehicleTimeRecord(float position, float velocity, float timestep) { + this.position = position; + this.velocity = velocity; + this.timestep = timestep; + } +} diff --git a/doc/classdiagram.graphml b/doc/classdiagram.graphml index 3e53e8a..b3a2c25 100644 --- a/doc/classdiagram.graphml +++ b/doc/classdiagram.graphml @@ -13,55 +13,52 @@ - + - - + - Vehicle + Vehicle - position: float -curVelocity: float -maxVelocity: float -brakeProp: float - timeElapse(timestep: int): void + # position: float +# curVelocity: float +# maxVelocity: float +# brakeProp: float + + timeElapse(timestep: float): void - - + Track - timeElapse(timestep: int): void + + timeElapse(timestep: float): void - - + VehicleTimeRecord - position: float -velocity: float -timestep: int + # position: float +# velocity: float +# timestep: float @@ -69,7 +66,6 @@ timestep: int - @@ -81,7 +77,6 @@ timestep: int - @@ -91,6 +86,22 @@ timestep: int + + + + + + + + + + + # forerunner + + + +