Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  Model.java

  Sprache: JAVA
 

package gui;

import gui.Vehicle.CarColor;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Observable;

class Model extends Observable implements Serializable {
 
 private static final long serialVersionUID = 1L;
 public static final int GRID_SIZE  = 50;
    public static final int VEHICLE_RANGE  = 10;
    
    private int colorNo = 0;
    CarColor[] colors;
    
    private Map<Long, Vehicle> vecCol =new HashMap<Long, Vehicle>();
    private HashMap<Long, HashSet<Long>> connections =new HashMap<Long, HashSet<Long>>();
    
    public Model() {
     colors = Vehicle.CarColor.values();
    }

    public void addVehicle(Long vecID){
     colorNo = colorNo % (colors.length);
        this.addVehicle(new Vehicle(vecID, colors[colorNo]));
     colorNo++;
    }
    
    public void addVehicle(Vehicle vehicle){
        if(!vecCol.containsKey(vehicle.getVechicleID()))
        {
            vecCol.put(vehicle.getVechicleID(),vehicle);
            connections.put(vehicle.getVechicleID(), new HashSet<Long>());
            
            // Notify observers
            setChanged();
            notifyObservers("newVehicle");
        }
    }

    public void connectVehicles(long vec, long vec2){
        if(connections.containsKey(vec)){

            connections.get(vec).add(vec2);
        }
    }

    public void disconnectVehicles(long vec, long vec2){
        if(connections.containsKey(vec)){

            connections.get(vec).remove(vec2);
        }
    }
    
    public void updatePosition(long vecId, int x, int y){
     if(vecCol.containsKey(vecId)){
      vecCol.get(vecId).SetPosition(x, y);
     }
    }
    
    public void updateDirection(long vecId, int dir){
     if(vecCol.containsKey(vecId)){
      vecCol.get(vecId).SetDirection(dir);
     }
    }

    public HashSet<Long> getConnectedVehicles(long vecId){
        if(connections.containsKey(vecId)){
            return connections.get(vecId);
        }
        
        return null;
    }

    public Collection<Vehicle> getVehicles(){
        return vecCol.values();
    }

    public void setLimits(int xLimit, int yLimit) {

         // Notify observers
        setChanged();
        notifyObservers("limits");
    }
    
    public void refresh() {
        // Notify observers
        setChanged();
        notifyObservers("refresh");
    }

    public void toggleRange(){
        setChanged();
        notifyObservers("range"); 
    }

    public void toggleConnections(){
        setChanged();
        notifyObservers("connections");
    }
    
    public void receivedMessage(long vecId){
     
     if(vecCol.containsKey(vecId)){
      vecCol.get(vecId).SetReceivedData();
     }
    }
}

Messung V0.5 in Prozent
C=93 H=94 G=93

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002