public Coffee next() {
   try {
     return (Coffee) types[rand.nextInt(types.length)].newInstance();
     // report programmer error at run time
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
示例#2
0
文件: Store.java 项目: hanqi91/tij4
 public Product next() {
   return new Product(
       rand.nextInt(1000), "Test", Math.round(rand.nextDouble() * 1000.0) + 0.99);
 }