Create classes Track, Vehicle and VehicleTimeRecord. Adjust class diagram.

This commit is contained in:
Loch Christian (uib05376) 2020-09-16 14:20:51 +02:00
parent 24b6a0c28b
commit e9820ebfd2
4 changed files with 106 additions and 19 deletions

View File

@ -0,0 +1,16 @@
package de.hems.trafficsim;
import java.util.LinkedList;
import java.util.List;
public class Track {
protected List<Vehicle> vehicles;
public Track() {
this.vehicles = new LinkedList<>();
}
public void timeElapse(float timeStep) {
}
}

View File

@ -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) {
}
}

View File

@ -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;
}
}

View File

@ -13,55 +13,52 @@
<key attr.name="description" attr.type="string" for="edge" id="d9"/> <key attr.name="description" attr.type="string" for="edge" id="d9"/>
<key for="edge" id="d10" yfiles.type="edgegraphics"/> <key for="edge" id="d10" yfiles.type="edgegraphics"/>
<graph edgedefault="directed" id="G"> <graph edgedefault="directed" id="G">
<data key="d0"/> <data key="d0" xml:space="preserve"/>
<node id="n0"> <node id="n0">
<data key="d4" xml:space="preserve"/> <data key="d4" xml:space="preserve"/>
<data key="d5"/>
<data key="d6"> <data key="d6">
<y:UMLClassNode> <y:UMLClassNode>
<y:Geometry height="244.90625" width="174.21875" x="128.0" y="108.0"/> <y:Geometry height="244.90625" width="227.0" x="272.00000000000006" y="186.99999999999994"/>
<y:Fill color="#FFCC00" transparent="false"/> <y:Fill color="#FFCC00" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/> <y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.92626953125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="49.525390625" x="62.3466796875" xml:space="preserve" y="3.0">Vehicle<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.92626953125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="49.525390625" x="88.7373046875" xml:space="preserve" y="3.0">Vehicle<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel>
<y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="true"> <y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="true">
<y:AttributeLabel xml:space="preserve">position: float <y:AttributeLabel xml:space="preserve"># position: float
curVelocity: float # curVelocity: float
maxVelocity: float # maxVelocity: float
brakeProp: float</y:AttributeLabel> # brakeProp: float</y:AttributeLabel>
<y:MethodLabel xml:space="preserve">timeElapse(timestep: int): void</y:MethodLabel> <y:MethodLabel xml:space="preserve">+ timeElapse(timestep: float): void</y:MethodLabel>
</y:UML> </y:UML>
</y:UMLClassNode> </y:UMLClassNode>
</data> </data>
</node> </node>
<node id="n1"> <node id="n1">
<data key="d4" xml:space="preserve"/> <data key="d4" xml:space="preserve"/>
<data key="d5"/>
<data key="d6"> <data key="d6">
<y:UMLClassNode> <y:UMLClassNode>
<y:Geometry height="171.0" width="227.0" x="377.0" y="80.5"/> <y:Geometry height="171.0" width="227.0" x="272.00000000000006" y="-73.49999999999989"/>
<y:Fill color="#FFCC00" transparent="false"/> <y:Fill color="#FFCC00" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/> <y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.92626953125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="38.68994140625" x="94.155029296875" xml:space="preserve" y="3.0">Track<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.92626953125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="38.68994140625" x="94.155029296875" xml:space="preserve" y="3.0">Track<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel>
<y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="true"> <y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="true">
<y:AttributeLabel xml:space="preserve"/> <y:AttributeLabel xml:space="preserve"/>
<y:MethodLabel xml:space="preserve">timeElapse(timestep: int): void</y:MethodLabel> <y:MethodLabel xml:space="preserve">+ timeElapse(timestep: float): void</y:MethodLabel>
</y:UML> </y:UML>
</y:UMLClassNode> </y:UMLClassNode>
</data> </data>
</node> </node>
<node id="n2"> <node id="n2">
<data key="d4" xml:space="preserve"/> <data key="d4" xml:space="preserve"/>
<data key="d5"/>
<data key="d6"> <data key="d6">
<y:UMLClassNode> <y:UMLClassNode>
<y:Geometry height="116.00000000000003" width="174.21875" x="-26.453125" y="-56.39999999999999"/> <y:Geometry height="116.00000000000003" width="174.21875" x="298.390625" y="528.5999999999997"/>
<y:Fill color="#FFCC00" transparent="false"/> <y:Fill color="#FFCC00" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/> <y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.92626953125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="124.65625" x="24.78125" xml:space="preserve" y="3.0">VehicleTimeRecord<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="19.92626953125" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="124.65625" x="24.78125" xml:space="preserve" y="3.0">VehicleTimeRecord<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel>
<y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="true"> <y:UML clipContent="true" constraint="" hasDetailsColor="false" omitDetails="false" stereotype="" use3DEffect="true">
<y:AttributeLabel xml:space="preserve">position: float <y:AttributeLabel xml:space="preserve"># position: float
velocity: float # velocity: float
timestep: int</y:AttributeLabel> # timestep: float</y:AttributeLabel>
<y:MethodLabel xml:space="preserve"/> <y:MethodLabel xml:space="preserve"/>
</y:UML> </y:UML>
</y:UMLClassNode> </y:UMLClassNode>
@ -69,7 +66,6 @@ timestep: int</y:AttributeLabel>
</node> </node>
<edge id="e0" source="n1" target="n0"> <edge id="e0" source="n1" target="n0">
<data key="d8" xml:space="preserve"/> <data key="d8" xml:space="preserve"/>
<data key="d9"/>
<data key="d10"> <data key="d10">
<y:PolyLineEdge> <y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
@ -81,7 +77,6 @@ timestep: int</y:AttributeLabel>
</edge> </edge>
<edge id="e1" source="n0" target="n2"> <edge id="e1" source="n0" target="n2">
<data key="d8" xml:space="preserve"/> <data key="d8" xml:space="preserve"/>
<data key="d9"/>
<data key="d10"> <data key="d10">
<y:PolyLineEdge> <y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
@ -91,6 +86,22 @@ timestep: int</y:AttributeLabel>
</y:PolyLineEdge> </y:PolyLineEdge>
</data> </data>
</edge> </edge>
<edge id="e2" source="n0" target="n0">
<data key="d8" xml:space="preserve"/>
<data key="d9" xml:space="preserve"><![CDATA[asdsad
]]></data>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
<y:Point x="198.50000000000006" y="309.45312499999994"/>
</y:Path>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="none" target="none"/>
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" verticalTextPosition="bottom" visible="true" width="69.373046875" x="-89.81295776367182" xml:space="preserve" y="51.952835083007756"># forerunner<y:LabelModel><y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/></y:LabelModel><y:ModelParameter><y:SmartEdgeLabelModelParameter angle="0.0" distance="30.0" distanceToCenter="true" position="right" ratio="0.5" segment="0"/></y:ModelParameter><y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/></y:EdgeLabel>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
</graph> </graph>
<data key="d7"> <data key="d7">
<y:Resources/> <y:Resources/>