@Test public void printSimpleHeart() throws Exception { System.out.println("full heart:"); OtherUtil.printSimpleHeart(true); System.out.println("half heart:"); OtherUtil.printSimpleHeart(false); }
public static void printSimpleHeart(boolean isFull) { for (double y = 1.5; y > -1.5; y -= 0.1) { for (double x = -1.5; x < 1.5; x += 0.05) { double a = x * x + y * y - 1; if (a * a * a - x * x * y * y * y <= 0) { System.out.print("*"); } else { if (isFull) { System.out.print(" "); } } } System.out.println(); } }
OtherUtil { public static void printSimpleHeart(boolean isFull) { for (double y = 1.5; y > -1.5; y -= 0.1) { for (double x = -1.5; x < 1.5; x += 0.05) { double a = x * x + y * y - 1; if (a * a * a - x * x * y * y * y <= 0) { System.out.print("*"); } else { if (isFull) { System.out.print(" "); } } } System.out.println(); } } }
OtherUtil { public static void printSimpleHeart(boolean isFull) { for (double y = 1.5; y > -1.5; y -= 0.1) { for (double x = -1.5; x < 1.5; x += 0.05) { double a = x * x + y * y - 1; if (a * a * a - x * x * y * y * y <= 0) { System.out.print("*"); } else { if (isFull) { System.out.print(" "); } } } System.out.println(); } } private  OtherUtil(); }
OtherUtil { public static void printSimpleHeart(boolean isFull) { for (double y = 1.5; y > -1.5; y -= 0.1) { for (double x = -1.5; x < 1.5; x += 0.05) { double a = x * x + y * y - 1; if (a * a * a - x * x * y * y * y <= 0) { System.out.print("*"); } else { if (isFull) { System.out.print(" "); } } } System.out.println(); } } private  OtherUtil(); static void printSimpleHeart(boolean isFull); static void printTwoHeart(); }
OtherUtil { public static void printSimpleHeart(boolean isFull) { for (double y = 1.5; y > -1.5; y -= 0.1) { for (double x = -1.5; x < 1.5; x += 0.05) { double a = x * x + y * y - 1; if (a * a * a - x * x * y * y * y <= 0) { System.out.print("*"); } else { if (isFull) { System.out.print(" "); } } } System.out.println(); } } private  OtherUtil(); static void printSimpleHeart(boolean isFull); static void printTwoHeart();  }