Advertisement
Guest User

Untitled

a guest
Nov 20th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. /**
  2. * Created by Menji on 2016-11-20.
  3. */
  4. public class TheLoveStory {
  5. private String me = "me";
  6. private String you = "you";
  7. private int date = 0;
  8. private String theTruth = "Love you mom.";
  9.  
  10. //contructor
  11. public TheLoveStory(String me, String you) {
  12. if (me.equals(this.me)) {
  13. if (you.equals(this.you)) {
  14. theBeginning();
  15. Thread thread = new Thread(new TimeCounter());
  16. thread.start();
  17. } else {
  18. System.out.println("you are not my mom </3");
  19. }
  20. } else System.out.println("you are not me </3");
  21. }
  22.  
  23. public void theBeginning() {
  24. if (date == 0) {
  25. System.out.println("One day i wake up in this world.");
  26. if ((me + " " + you).equals("me you")) {
  27. System.out.println("you are beside me.");
  28. System.out.println(theTruth);
  29. } else {
  30. System.out.println("Something is wrong");
  31. }
  32. } else {
  33. System.out.println("Something is wrong");
  34. }
  35. }
  36.  
  37. //private class with one therad inside
  38. private class TimeCounter implements Runnable {
  39. private int counter = 0;
  40. private boolean threadStatus = true;
  41.  
  42. @Override
  43. public void run() {
  44. while (threadStatus) {
  45. for (int i = counter; i < 8; counter++) {
  46. if (counter == 0) {
  47. System.out.println("\n" + "The time is going...");
  48. System.out.println("I'm growing up.");
  49. } else if (counter == 1) {
  50. System.out.println("\n" + "The time is going...");
  51. System.out.println("You teached me how to kill mobs.");
  52. System.out.println(theTruth);
  53. } else if (counter == 2) {
  54. System.out.println("\n" + "The time is going...");
  55. System.out.println("You helped me with quest lines.");
  56. System.out.println(theTruth);
  57. } else if (counter == 3) {
  58. System.out.println("\n" + "The time is going...");
  59. System.out.println("You protected me when i'm in denger.");
  60. System.out.println(theTruth);
  61. } else if (counter == 4) {
  62. System.out.println("\n" + "The time is going...");
  63. System.out.println("You gave me hope when i needed.");
  64. System.out.println(theTruth);
  65. } else if (counter == 5) {
  66. System.out.println("\n" + "The time is going...");
  67. System.out.println("You means everything for me.");
  68. System.out.println(theTruth);
  69. } else if (counter == 6) {
  70. System.out.println("\n" + "The time is going...");
  71. System.out.println("Here is a heart for you:" + "\n");
  72. } else if (counter == 7) {
  73. drawHeart();
  74. System.out.println("\n" + "From: your lovely daughter<3");
  75. }
  76.  
  77. try {
  78. Thread.sleep(5000);
  79. } catch (InterruptedException e) {
  80. e.printStackTrace();
  81. }
  82. }
  83. }
  84. }
  85.  
  86. //just in case :D
  87. public void stop() {
  88. threadStatus = false;
  89. Thread.currentThread().interrupt();
  90. }
  91. }
  92.  
  93. //source code : http://www.java-forums.org/java-2d/25333-drawing-heart-valentine.html
  94. public void drawHeart() {
  95. int width = 20;
  96. int height = 15;
  97. String[] lines = new String[height];
  98.  
  99. int p1 = width / 2;
  100. int p2 = width / 2;
  101. int p3 = width / 2;
  102. int p4 = width / 2;
  103.  
  104. boolean topPart = false;
  105.  
  106. for (int i = height - 1; i >= 0; i--) {
  107. StringBuilder l = new StringBuilder();
  108. if (p1 == 0) {
  109. topPart = true;
  110. }
  111. if (topPart) {
  112. int col = 0;
  113. while (col++ < p1) {
  114. l.append(" ");
  115. }
  116. l.append("*");
  117. while (col++ < p3) {
  118. l.append(" ");
  119. }
  120. l.append("*");
  121. if (p4 > p3) {
  122. while (col++ < p4) {
  123. l.append(" ");
  124. }
  125. l.append("*");
  126. }
  127. while (col++ < p2) {
  128. l.append(" ");
  129. }
  130. l.append("*");
  131.  
  132. p1++;
  133. p2--;
  134. p3--;
  135. p4++;
  136. } else {
  137. int col = 0;
  138. while (col++ < p1) {
  139. l.append(" ");
  140. }
  141. l.append("*");
  142. if (p2 > p1) {
  143. while (col++ < p2) {
  144. l.append(" ");
  145. }
  146. l.append("*");
  147. }
  148. p1--;
  149. p2++;
  150. }
  151. lines[i] = l.toString();
  152.  
  153. }
  154.  
  155. for (String line : lines) {
  156. System.out.println(line);
  157. }
  158. }
  159.  
  160. // the start of the love story
  161. public static void main(String[] args) {
  162. TheLoveStory theLoveStory = new TheLoveStory("me", "you");
  163. }
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement