Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /*
- Get Current Date and Time: java.text.SimpleDateFormat
- import java.text.SimpleDateFormat;
- import java.util.Date;
- public class CurrentDateTimeExample2 {
- public static void main(String[] args) {
- SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
- Date date = new Date();
- System.out.println(formatter.format(date));
- }
- }
- */
- // For time
- import java.util.Date;
- import java.text.SimpleDateFormat;
- public class NightBot extends Bot {
- // Extra Variables
- ArrayList <String> commands;
- // Constructor
- NightBot(){
- super();
- commands = new ArrayList <String> ();
- }
- NightBot(String name, Streamer owner){
- super(name, owner);
- commands = new ArrayList <String> ();
- commands.add("!help");
- commands.add("!quiet");
- commands.add("!time");
- commands.add("!socials");
- }
- NightBot(String name, Streamer owner, ArrayList <String> commands){
- super(name, owner);
- this.commands = commands;
- }
- // Methods
- void showStatus(){
- super.showStatus();
- System.out.println();
- System.out.println("Commands of " + name + ": ");
- if(commands.size() == 0){
- System.out.println("Bot " + name + " has no commands yet.");
- }
- else{
- for(int i=0; i<commands.size(); i++){
- System.out.println("Command " + (i+1) + ": " + commands.get(i));
- }
- }
- System.out.println("*********************************");
- } // END OF FUNCTION SHOWSTATUS
- // COMMANDS / METHODS
- void help() {
- System.out.println("NightBot's commands: ");
- for(int i=0; i<commands.size(); i++) {
- System.out.println("Command " + i + ": " + commands.get(i));
- }
- System.out.println();
- } // END OF FUNCTION HELP
- void quiet(){
- System.out.println("Be quiet please! The baby is still sleeping...");
- }
- void whatsTheTime(){
- System.out.println("What's the time and date this day?");
- SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
- Date date = new Date();
- System.out.println(formatter.format(date));
- }
- void socials() {
- owner.showSocials();
- }
- // METHOD FOR SELECTING FUNCTION
- void selectMethodByCommand(String command) {
- if(command.equals(commands.get(0))) {
- help();
- }
- else if(command.equals(commands.get(1))) {
- quiet();
- }
- else if(command.equals(commands.get(2))) {
- whatsTheTime();
- }
- else if(command.equals(commands.get(3))) {
- socials();
- }
- }
- } // END OF CLASS NIGHTBOT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement