Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/desktop/test/deployment/active/   (LibreOffice Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 3 kB image not shown  

Quellcode-Bibliothek 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=98 H=100 G=98

¤ 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.0.1Bemerkung:  (vorverarbeitet am  2026-09-29) ¤

*Bot Zugriff






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.