Advertisement
desislava_topuzakova

01. Advertisement Message

Oct 29th, 2022
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package ObjectEx.Message;
  2.  
  3. import java.util.Random;
  4.  
  5. public class Message {
  6.  
  7. private Random random = new Random();
  8.  
  9. private String[] phrases = {"Excellent product.", "Such a great product.",
  10. "I always use that product.", "Best product of its category."
  11. , "Exceptional product.", "I can’t live without this product."};
  12. private String[] events = {"Now I feel good.", "I have succeeded with this product.",
  13. "Makes miracles. I am happy of the results!",
  14. "I cannot believe but now I feel awesome.",
  15. "Try it yourself, I am very satisfied.", "I feel great!"};
  16. private String[] author = {"Diana", "Petya", "Stella", "Elena", "Katya", "Iva", "Annie", "Eva"};
  17. private String[] town = {"Burgas", "Sofia", "Plovdiv", "Varna", "Ruse"};
  18.  
  19. public String randomMessenge() {
  20.  
  21. return String.format("%s %s %s - %s",
  22. phrases[random.nextInt(phrases.length)],
  23. events[random.nextInt(events.length)],
  24. author[random.nextInt(author.length)],
  25. town[random.nextInt(town.length)]);
  26. }
  27. }
  28.  
  29.  
  30. package ObjectEx.Message;
  31.  
  32. import java.util.Scanner;
  33.  
  34. public class Main {
  35. public static void main(String[] args) {
  36. Scanner scanner = new Scanner(System.in);
  37.  
  38. Message message = new Message();
  39. int n = Integer.parseInt(scanner.nextLine());
  40.  
  41. for (int i = 0; i < n; i++) {
  42. String output = message.randomMessenge();
  43. System.out.println(output);
  44. }
  45. }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement