1 24 package org.objectweb.jalisto.se.test.data; 25 26 import java.io.Serializable ; 27 28 public class Format implements Serializable { 29 30 public Format() { 31 } 32 33 public boolean equals(Object o) { 34 try { 35 Format candidate = (Format) o; 36 return ((candidate.width == this.width) && (candidate.length == this.length)); 37 } catch (ClassCastException cce) { 38 } 39 return false; 40 } 41 42 public String toString() { 43 return String.valueOf(width) + "x" + String.valueOf(length); 44 } 45 46 public static Format getNewFormat(int i) { 47 Format result = new Format(); 48 result.width = ((i * 1684657) % 20) + 1; 49 result.length = ((i * 48987657) % 15) + 1; 50 return result; 51 } 52 53 public static Format getFormat() { 54 counter++; 55 return availableFormat[counter % availableFormat.length]; 56 } 57 58 int width; 59 int length; 60 61 public static int counter = -1; 62 63 public static Format[] availableFormat = {getNewFormat(1), 64 getNewFormat(2), 65 getNewFormat(3), 66 getNewFormat(4), 67 getNewFormat(5), 68 getNewFormat(6), 69 getNewFormat(7)}; 70 71 72 static final long serialVersionUID = -7589377091484761459L; 73 } 74 | Popular Tags |