Пример #1
0
  public static void main(String[] args) throws CloneNotSupportedException {
    // returns cloned object
    Prototype music = PrototypeFactory.getInstance(ModelType.MUSIC);
    music.setName("Pehli Bar");
    System.out.println(music.toString());

    // returns cloned object
    music = PrototypeFactory.getInstance(ModelType.MUSIC);
    music.setName("Dil Dhadkane Do");
    System.out.println(music.toString());
  }
Пример #2
0
  public static void main(String[] args) {
    try {
      String moviePrototype =
          PrototypeFactory.getInstance(PrototypeFactory.ModelType.MOVIE).toString();
      System.out.println(moviePrototype);

      String showPrototype =
          PrototypeFactory.getInstance(PrototypeFactory.ModelType.SHOW).toString();
      System.out.println(showPrototype);

    } catch (CloneNotSupportedException e) {
      e.printStackTrace();
    }
  }
 private PrototypeFactoryTest verify(int markerval) {
   marker = markerval;
   PrototypeFactoryTest obj = (PrototypeFactoryTest) fact.factory_create();
   org.junit.Assert.assertSame(getClass(), obj.getClass());
   org.junit.Assert.assertNotSame(obj, this);
   org.junit.Assert.assertEquals(markerval, obj.marker);
   org.junit.Assert.assertEquals(markerval, this.marker);
   return obj;
 }