package javalabs.lab4.first;

public class Vehicle {
    protected int _mass;
    protected int _velocity;

    public Vehicle(int mass, int velocity) {
        _mass = mass;
        _velocity = velocity;
    }

    public int getMass() { return _mass; }
    public void setMass(int mass) { _mass = mass; }

    public int getVelocity() { return _velocity; }
    public void setVelocity(int velocity) { _velocity = velocity; }

    public void move() { System.out.println(_velocity); }

    public void display() {
        System.out.printf("%s: mass=%d, velocity=%d\n",
                this.getClass().getSimpleName(), _mass, _velocity);
    }

    @Override
    public String toString() {
        String result = "{\"type\": \"" + this.getClass().getSimpleName()
                + "\", \"mass\": " + _mass
                + ", \"velocity\": " + _velocity + "}";
        return result;
    }
}
