Advertisement
Guest User

klasa

a guest
May 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package serializacja;
  7.  
  8. import java.io.Externalizable;
  9. import java.io.IOException;
  10. import java.io.ObjectInput;
  11. import java.io.ObjectOutput;
  12. import java.io.Serializable;
  13.  
  14. /**
  15.  *
  16.  * @author Piotr Zuber
  17.  */
  18. public class Pracownik implements Serializable, Externalizable{
  19.    
  20.     private String Imie,Nazwisko;
  21.     private int Wyplata;
  22.    
  23.     public Pracownik()
  24.     {
  25.         Imie="Andrzej";
  26.         Nazwisko="Kowalski";
  27.         Wyplata = 2500;
  28.     }
  29.      public Pracownik(String im,String nz,int w)
  30.     {
  31.         Imie=im;
  32.         Nazwisko=nz;
  33.         Wyplata =w;
  34.     }
  35.  
  36.     public String getImie() {
  37.         return Imie;
  38.     }
  39.  
  40.     public String getNazwisko() {
  41.         return Nazwisko;
  42.     }
  43.  
  44.     public int getWyplata() {
  45.         return Wyplata;
  46.     }
  47.  
  48.      
  49.      
  50.     @Override
  51.     public void writeExternal(ObjectOutput oo) throws IOException {
  52.         oo.writeObject(Imie+"Dupa");
  53.        // oo.writeObject("Dawid");
  54.         oo.writeObject(Nazwisko);
  55.         oo.writeObject(Wyplata);  
  56.     }
  57.  
  58.     @Override
  59.     public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
  60.         Imie = (String)oi.readObject();
  61.         //String x = (String)oi.readObject();
  62.         Nazwisko = (String)oi.readObject();
  63.         Wyplata = (int)oi.readObject();
  64.     }
  65.    
  66.    
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement