Advertisement
makispaiktis

Streaming - NightBot.java

Nov 11th, 2019 (edited)
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. import java.util.*;
  2.  
  3.  
  4. /*
  5. Get Current Date and Time: java.text.SimpleDateFormat
  6. import java.text.SimpleDateFormat;  
  7. import java.util.Date;  
  8. public class CurrentDateTimeExample2 {  
  9. public static void main(String[] args) {  
  10.     SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");  
  11.     Date date = new Date();  
  12.     System.out.println(formatter.format(date));  
  13.     }  
  14. }
  15. */
  16.  
  17.  
  18. // For time
  19. import java.util.Date;
  20. import java.text.SimpleDateFormat;
  21.  
  22. public class NightBot extends Bot {
  23.    
  24.     // Extra Variables
  25.     ArrayList <String> commands;
  26.    
  27.     // Constructor
  28.     NightBot(){
  29.         super();
  30.         commands = new ArrayList <String> ();
  31.     }
  32.    
  33.     NightBot(String name, Streamer owner){
  34.         super(name, owner);
  35.         commands = new ArrayList <String> ();
  36.         commands.add("!help");
  37.         commands.add("!quiet");
  38.         commands.add("!time");
  39.         commands.add("!socials");
  40.  
  41.     }
  42.    
  43.     NightBot(String name, Streamer owner, ArrayList <String> commands){
  44.         super(name, owner);
  45.         this.commands = commands;
  46.     }
  47.    
  48.    
  49.     // Methods
  50.     void showStatus(){
  51.         super.showStatus();
  52.         System.out.println();
  53.         System.out.println("Commands of " + name + ": ");
  54.         if(commands.size() == 0){
  55.             System.out.println("Bot " + name + " has no commands yet.");
  56.         }
  57.         else{
  58.             for(int i=0; i<commands.size(); i++){
  59.                 System.out.println("Command " + (i+1) + ": " + commands.get(i));
  60.             }
  61.         }
  62.        
  63.         System.out.println("*********************************");
  64.     }   //  END OF FUNCTION SHOWSTATUS
  65.    
  66.    
  67.     // COMMANDS / METHODS
  68.     void help() {
  69.         System.out.println("NightBot's commands: ");
  70.         for(int i=0; i<commands.size(); i++) {
  71.             System.out.println("Command " + i + ": " + commands.get(i));
  72.         }
  73.         System.out.println();
  74.     }   // END OF FUNCTION HELP
  75.    
  76.     void quiet(){
  77.         System.out.println("Be quiet please! The baby is still sleeping...");
  78.     }
  79.    
  80.     void whatsTheTime(){
  81.         System.out.println("What's the time and date this day?");
  82.         SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
  83.         Date date = new Date();
  84.         System.out.println(formatter.format(date));
  85.     }
  86.    
  87.        
  88.     void socials() {
  89.         owner.showSocials();
  90.     }
  91.    
  92.    
  93.     // METHOD FOR SELECTING FUNCTION
  94.     void selectMethodByCommand(String command) {
  95.         if(command.equals(commands.get(0))) {
  96.             help();
  97.         }
  98.         else if(command.equals(commands.get(1))) {
  99.             quiet();
  100.         }
  101.         else if(command.equals(commands.get(2))) {
  102.             whatsTheTime();
  103.         }
  104.         else if(command.equals(commands.get(3))) {
  105.             socials();
  106.         }
  107.     }
  108.    
  109. }   // END OF CLASS NIGHTBOT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement