1 24 package org.objectweb.jalisto.samples.basic.data; 25 26 public class Book { 27 28 private String title; 29 private String author; 30 private int price; 31 32 public Book() { 33 } 34 35 public Book(String title, String author, int price) { 36 this.title = title; 37 this.author = author; 38 this.price = price; 39 } 40 41 public String getAuthor() { 42 return author; 43 } 44 45 public void setAuthor(String author) { 46 this.author = author; 47 } 48 49 public int getPrice() { 50 return price; 51 } 52 53 public void setPrice(int price) { 54 this.price = price; 55 } 56 57 public String getTitle() { 58 return title; 59 } 60 61 public void setTitle(String title) { 62 this.title = title; 63 } 64 65 public Object [] toArray() { 66 Object [] result = new Object [4]; 67 result[0] = title; 68 result[1] = author; 69 result[2] = new Integer (price); 70 return result; 71 } 72 73 public static Book toBook(Object [] array) { 74 Book book = new Book(); 75 book.setTitle((String ) array[0]); 76 book.setAuthor((String ) array[1]); 77 book.setPrice(((Integer ) array[2]).intValue()); 78 return book; 79 } 80 } 81 | Popular Tags |