SimpleFactoryTest.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package main;// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
  2. // then press Enter. You can now see whitespace characters in your code.
  3. public class SimpleFactoryTest
  4. {
  5. public static void main(String[] args)
  6. {
  7. try
  8. {
  9. SimpleFactory.createProduct("A").show();
  10. }
  11. catch (NullPointerException e)
  12. {
  13. System.out.println("没有A这款产品,无法生产~");
  14. }
  15. try
  16. {
  17. SimpleFactory.createProduct("B").show();
  18. }
  19. catch (NullPointerException e)
  20. {
  21. System.out.println("没有B这款产品,无法生产~");
  22. }
  23. try
  24. {
  25. SimpleFactory.createProduct("C").show();
  26. }
  27. catch (NullPointerException e)
  28. {
  29. System.out.println("没有C这款产品,无法生产~");
  30. }
  31. try
  32. {
  33. SimpleFactory.createProduct("D").show();
  34. }
  35. catch (NullPointerException e)
  36. {
  37. System.out.println("没有D这款产品,无法生产~");
  38. }
  39. }
  40. }