All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.kit.ifv.mobitopp.simulation.car.DefaultPrivateCar Maven / Gradle / Ivy

Go to download

mobiTopp (http://mobitopp.ifv.kit.edu/) is an agent-based travel demand model developed at the Institute for transport studies at the Karlsruhe Institute of Technology (http://www.ifv.kit.edu/english/index.php). Publications about mobiTopp can be found on the project site (http://mobitopp.ifv.kit.edu/28.php).

The newest version!
package edu.kit.ifv.mobitopp.simulation.car;

import java.io.Serializable;

import edu.kit.ifv.mobitopp.data.Zone;
import edu.kit.ifv.mobitopp.data.person.PersonId;
import edu.kit.ifv.mobitopp.simulation.Car;
import edu.kit.ifv.mobitopp.simulation.Household;

public class DefaultPrivateCar extends CarDecorator implements PrivateCar, Car, Serializable {

	private static final long serialVersionUID = 1L;

	protected final Household owner;
	protected final PersonId mainUser;
	protected final PersonId personalUser;

	public DefaultPrivateCar(
		Car car,
		Household owner,
		PersonId mainUser,
		PersonId personalUser
	) {
		super(car);

		assert owner != null;
		assert mainUser != null;

		this.owner = owner;
		this.mainUser = mainUser;
		this.personalUser = personalUser;
	}
	
	public Car car() {
		return car;
	}

	public Household owner() {
		return this.owner;
	}

	public boolean isPersonal() {
		return this.personalUser != null;
	}

	public PersonId personalUser() {
		return this.personalUser;
	}

	public PersonId mainUser() {
		return this.mainUser;
	}
	
	@Override
	public void returnCar(Zone zone) {
	  super.returnCar(zone);
	  owner.returnCar(this);
	}

	@Override
	public String forLogging() {
		StringBuffer buffer = new StringBuffer();

		String personal = isPersonal() ? "1" : "0";
	
		buffer.append(owner.getOid() + "; ");
		buffer.append(mainUser.getOid() + "; ");
		buffer.append(personal + "; ");
		buffer.append(car.forLogging());

		return buffer.toString();
	}

	public String statusForLogging() {

		return car.statusForLogging();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy