Advertisement
makispaiktis

Streaming - StreamBot.java

Nov 16th, 2019 (edited)
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.55 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class StreamBot extends Bot {
  4.    
  5.     // Variables
  6.     Stream stream;
  7.     ArrayList <String> commands;
  8.    
  9.     // Constructors
  10.     StreamBot(){
  11.         super();
  12.         stream = new Stream();
  13.         commands = new ArrayList <String> ();
  14.     }
  15.    
  16.     StreamBot(String name, Streamer owner, Stream stream){
  17.         super(name, owner);
  18.         this.stream = stream;
  19.         commands = new ArrayList <String> ();
  20.         commands.add("!help");
  21.         commands.add("!info");
  22.         commands.add("!uptime");
  23.     }
  24.    
  25.     StreamBot(String name, Streamer owner, Stream stream, ArrayList <String> commands){
  26.         super(name, owner);
  27.         this.stream = stream;
  28.         this.commands = commands;
  29.     }
  30.    
  31.    
  32.     // METHODS
  33.     void showStatus() {
  34.         super.showStatus();
  35.         System.out.println("Stream: " + stream.title + " (" + stream.gameBeenPlaying + ")");
  36.         System.out.println();
  37.         System.out.println("Commands of " + name + ": ");
  38.         if(commands.size() == 0){
  39.             System.out.println("Bot " + name + " has no commands yet.");
  40.         }
  41.         else{
  42.             for(int i=0; i<commands.size(); i++){
  43.                 System.out.println("Command " + (i+1) + ": " + commands.get(i));
  44.             }
  45.         }
  46.        
  47.         System.out.println("*********************************");
  48.     }   // END OF FUNCTION SHOWSTATUS
  49.    
  50.    
  51.    
  52.     // Commands / Methods
  53.     void help() {
  54.         System.out.println("StreamBot's commands: ");
  55.         for(int i=0; i<commands.size(); i++) {
  56.             System.out.println("Command " + i + ": " + commands.get(i));
  57.         }
  58.         System.out.println();
  59.     }   // END OF FUNCTION HELP
  60.    
  61.    
  62.     void info() {
  63.         System.out.println(owner.name + " also known as '" + owner.nameOfChannel + "' is now livestreaming the game " + stream.gameBeenPlaying);
  64.         System.out.println("He is " + owner.age + " years old and is " + owner.nationality);
  65.         System.out.println("The game he usually plays are similar to the following categories: ");
  66.         for(int i=0; i<stream.categories.size(); i++) {
  67.             if(i != stream.categories.size() - 1) {
  68.                 System.out.print(stream.categories.get(i) + ", ");
  69.             }
  70.             else {
  71.                 System.out.print(stream.categories.get(i));
  72.             }
  73.         }
  74.     }
  75.    
  76.    
  77.     int uptime() {
  78.         // I will return the following value
  79.         return stream.secondsStreaming;
  80.         // Then, in main function (class App), I will add the seconds of the running function main in this value (secondsStreaming)
  81.     }
  82.    
  83.    
  84.     // METHOD FOR SELECTING FUNCTION
  85.         void selectMethodByCommand(String command) {
  86.             if(command.equals(commands.get(0))) {
  87.                 help();
  88.             }
  89.             else if(command.equals(commands.get(1))) {
  90.                 info();
  91.             }
  92.             else if(command.equals(commands.get(2))) {
  93.                 uptime();
  94.             }
  95.         }
  96.    
  97.    
  98.    
  99.    
  100. }   // END OF CLASS STREAMBOT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement