/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package userclasses;

import com.sun.lwuit.io.Externalizable;
import com.sun.lwuit.io.util.Util;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 *
 * @author ali
 */
public class Car implements Externalizable {
    private int model;
    private String name;
    
    public Car () { }
    
    public Car (String name, int model) {
        this.name = name;
        this.model = model;
    }

    /**
     * @return the model
     */
    public int getModel() {
        return model;
    }

    /**
     * @param model the model to set
     */
    public void setModel(int model) {
        this.model = model;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    public int getVersion() {
        return 1;
    }

    public void externalize(DataOutputStream stream) throws IOException {
        Util.writeUTF(name, stream);
        stream.writeInt(model);
    }

    public void internalize(int i, DataInputStream stream) throws IOException {
        name = stream.readUTF();
        model = stream.readInt();
    }

    public String getObjectId() {
        return "Car";
    }
    
    public String toString() {
        return "model:" + model + " by:" + name;
    }
    
    
}
