fork download
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package userclasses;
  6.  
  7. import com.sun.lwuit.io.Externalizable;
  8. import com.sun.lwuit.io.util.Util;
  9. import java.io.DataInputStream;
  10. import java.io.DataOutputStream;
  11. import java.io.IOException;
  12.  
  13. /**
  14.  *
  15.  * @author ali
  16.  */
  17. public class Car implements Externalizable {
  18. private int model;
  19. private String name;
  20.  
  21. public Car () { }
  22.  
  23. public Car (String name, int model) {
  24. this.name = name;
  25. this.model = model;
  26. }
  27.  
  28. /**
  29.   * @return the model
  30.   */
  31. public int getModel() {
  32. return model;
  33. }
  34.  
  35. /**
  36.   * @param model the model to set
  37.   */
  38. public void setModel(int model) {
  39. this.model = model;
  40. }
  41.  
  42. /**
  43.   * @return the name
  44.   */
  45. public String getName() {
  46. return name;
  47. }
  48.  
  49. /**
  50.   * @param name the name to set
  51.   */
  52. public void setName(String name) {
  53. this.name = name;
  54. }
  55.  
  56. public int getVersion() {
  57. return 1;
  58. }
  59.  
  60. public void externalize(DataOutputStream stream) throws IOException {
  61. Util.writeUTF(name, stream);
  62. stream.writeInt(model);
  63. }
  64.  
  65. public void internalize(int i, DataInputStream stream) throws IOException {
  66. name = stream.readUTF();
  67. model = stream.readInt();
  68. }
  69.  
  70. public String getObjectId() {
  71. return "Car";
  72. }
  73.  
  74. public String toString() {
  75. return "model:" + model + " by:" + name;
  76. }
  77.  
  78.  
  79. }
  80.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty