You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- package de.hems.trafficsim;
-
- import androidx.appcompat.app.AppCompatActivity;
-
- import android.os.Bundle;
- import android.view.View;
- import android.widget.TextView;
-
- import java.util.Observable;
- import java.util.Observer;
-
- public class MainActivity extends AppCompatActivity implements Observer {
-
- protected Track track;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- this.track = new Track(20);
- this.track.addObserver(this);
-
- }
-
- @Override
- public void update(Observable observable, Object o) {
- String s = "";
- for (Vehicle v: this.track.getVehicles()){
- s+= "Vehicle " + v.id + " | "
- + "Pos = " + v.getPosition() + " | "
- + "Vel = " + v.getCurVelocity()+ " | "
- + "\n";
- ;
- }
- TextView view = (TextView) findViewById(R.id.debugTextView);
- view.setText(s);
- view.invalidate();
- }
-
- public void onStepButtonClick (View view) {
- for (int j = 0; j < 3000; j++) {
- this.track.timeElapse(50);
- }
- }
- }
|