Advertisement
Kuebjii

Kuebjii's Console V1.1

Dec 16th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.35 KB | None | 0 0
  1. import javafx.scene.paint.Stop;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.Scanner;
  6. import java.util.Random;
  7. import java.util.concurrent.TimeUnit;
  8. import java.awt.Graphics;
  9.  
  10. class Colors {
  11.     public static final String RESET = "\u001B[0m";
  12.     public static final String BLACK = "\u001B[30m";
  13.     public static final String RED = "\u001B[31m";
  14.     public static final String GREEN = "\u001B[32m";
  15.     public static final String YELLOW = "\u001B[33m";
  16.     public static final String BLUE = "\u001B[34m";
  17.     public static final String PURPLE = "\u001B[35m";
  18.     public static final String CYAN = "\u001B[36m";
  19.     public static final String WHITE = "\u001B[37m";
  20. }
  21.  
  22. public class Main {
  23.  
  24.     public static void input() {
  25.         Scanner reader = new Scanner(System.in);
  26.         System.out.print(Colors.GREEN + "> " + Colors.RESET);
  27.         String input = reader.nextLine();
  28.  
  29.         if (input.equals("hello") || input.equals("HELLO")) {
  30.             System.out.println("Hello World!");
  31.             input();
  32.         }
  33.         if (input.equals("help")) {
  34.             System.out.println(Colors.RED + "Commands:" + Colors.RESET);
  35.             System.out.println(Colors.RED + "hello - outputs Hello World" + Colors.RESET);
  36.             System.out.println(Colors.RED + "help - you're already here" + Colors.RESET);
  37.             System.out.println(Colors.RED + "shutdown - shuts the console down" + Colors.RESET);
  38.             System.out.println(Colors.RED + "exit - shuts the console down" + Colors.RESET);
  39.             System.out.println(Colors.RED + "run - runs a program" + Colors.RESET);
  40.             System.out.println(Colors.RED + "run help - displays all programs you can run" + Colors.RESET);
  41.             System.out.println(Colors.RED + "back - takes you back to the main menu" + Colors.RESET);
  42.             System.out.println(Colors.RED + "time - says your current time and date" + Colors.RESET);
  43.             System.out.println(Colors.RED + "flip - flips a coin" + Colors.RESET);
  44.             input();
  45.         }
  46.         if (input.equals("shutdown") || input.equals("exit")) {
  47.             System.exit(0);
  48.         }
  49.         if (input.equals("run help")) {
  50.             System.out.println(Colors.RED + "Programs:" + Colors.RESET);
  51.             System.out.println(Colors.RED + "scalculator - shape calculator, defines area, circumference, and similar items" + Colors.RESET);
  52.             System.out.println(Colors.RED + "calculator - simple calculator" + Colors.RESET);
  53.             input();
  54.         }
  55.  
  56.         if (input.equals("run calculator")) {
  57.             normalCalculator();
  58.         }
  59.  
  60.         if (input.equals("run scalculator")) {
  61.             KuebjiiCalculatorMenu();
  62.         }
  63.  
  64.         if (input.equals("back"))
  65.         {
  66.             mainMenu();
  67.         }
  68.  
  69.         if (input.equals("time"))
  70.         {
  71.             SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
  72.             Date date = new Date(System.currentTimeMillis());
  73.             System.out.println(formatter.format(date));
  74.             input();
  75.         }
  76.         if (input.equals("flip"))
  77.         {
  78.             if (Math.random() < 0.5){
  79.                 System.out.println("Heads");
  80.             }else{
  81.                 System.out.println("Tails");
  82.             }
  83.         }
  84.         if (input.equals("clear"))
  85.         {
  86.             System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();
  87.             System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();
  88.             System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();
  89.             input();
  90.         }
  91.         else
  92.         {
  93.             System.out.println("Command: " + input + " was not found!");
  94.             mainMenu();
  95.         }
  96.     }
  97.  
  98.     public static void mainMenu() {
  99.         Scanner reader = new Scanner(System.in);
  100.         System.out.println(Colors.RED + "Kuebjii's Console" + Colors.RESET);
  101.         System.out.println(Colors.RED + "Please enter your comamand below" + Colors.RESET);
  102.         System.out.println();
  103.         input();
  104.     }
  105.  
  106.     public static void main(String[] args) throws InterruptedException {
  107.         Scanner reader = new Scanner(System.in);
  108.         System.out.print(Colors.GREEN + "> " + Colors.RESET);
  109.         String input = reader.findInLine("start");
  110.  
  111.         if (input.equals("start")) {
  112.             System.out.println(Colors.GREEN + "Booting Console" + Colors.RESET);
  113.             Thread.sleep(500);
  114.             System.out.println(Colors.GREEN + "Console Loaded" + Colors.RESET);
  115.             Thread.sleep(500);
  116.             System.out.println(Colors.GREEN + "Showing Console Now!" + Colors.RESET);
  117.             Thread.sleep(50);
  118.             mainMenu();
  119.         } else {
  120.             System.out.println("System.Start Error: Entered unknown command");
  121.         }
  122.     }
  123.  
  124.     /// ######################################################################## SHAPE CALCULATOR ######## DO NOT TOUCH ########################################################
  125.     public static void KuebjiiCalculatorMenu() {
  126.         Scanner reader = new Scanner(System.in);
  127.         System.out.println("Welcome to Kuebjii's Calculator");
  128.         System.out.println("Circle");
  129.         System.out.println("Square");
  130.         System.out.println("Rectangle");
  131.         System.out.println("Please type out the number you would like to use");
  132.         String input = reader.nextLine();
  133.         if (input.equals("circle")) {
  134.             circles();
  135.         }
  136.         if (input.equals("square")) {
  137.             squares();
  138.         }
  139.         if (input.equals("rectangle")) {
  140.             rectangle();
  141.         }
  142.         if (input.equals("devmode")) {
  143.             devMode();
  144.         }
  145.         if (input.equals("back")) {
  146.             mainMenu();
  147.         }
  148.     }
  149.  
  150.     public static void rectangle() {
  151.         Scanner reader = new Scanner(System.in);
  152.         System.out.println("Please enter the length of the rectangle");
  153.         double length = reader.nextDouble();
  154.         System.out.println("Please enter the width of the rectangle");
  155.         double width = reader.nextDouble();
  156.  
  157.         double perimeter = 2 * (length * width);
  158.         double area = length * width;
  159.  
  160.         System.out.println("Here is the perimeter of the rectangle: " + perimeter);
  161.         System.out.println("Here is the area of the rectangle: " + area);
  162.         System.out.println();
  163.         KuebjiiCalculatorMenu();
  164.  
  165.     }
  166.  
  167.     public static void squares() {
  168.         Scanner reader = new Scanner(System.in);
  169.         System.out.println("Please enter one side of the square");
  170.         double side = reader.nextDouble();
  171.         double perimeter;
  172.         double area;
  173.  
  174.         perimeter = side + side + side + side;
  175.         area = side * side;
  176.  
  177.         System.out.println("Here is the perimeter of the square: " + perimeter);
  178.         System.out.println("Here is the area of the square: " + area);
  179.         System.out.println();
  180.         KuebjiiCalculatorMenu();
  181.  
  182.     }
  183.  
  184.     public static void circles() {
  185.         System.out.println("What is the radius of the circle?");
  186.         Scanner reader = new Scanner(System.in);
  187.         double radius = reader.nextDouble();
  188.         double circumference;
  189.         double area;
  190.         circumference = 2 * 3.14 * radius;
  191.         area = 3.14 * radius * radius;
  192.         System.out.println("Here is the circumference of the circle" + circumference);
  193.         System.out.println("Here is the area of the circle" + area);
  194.         System.out.println();
  195.         KuebjiiCalculatorMenu();
  196.     }
  197.  
  198.     public static void devMode() {
  199.         Scanner reader = new Scanner(System.in);
  200.         System.out.println("D E V   C O N S O L E");
  201.         System.out.println("1. Circle");
  202.         System.out.println("2. Square");
  203.         System.out.println("3. Rectangle");
  204.         System.out.println("4. Testing Cycle");
  205.         int selector = reader.nextInt();
  206.         if (selector == 1) {
  207.             System.out.println("What is the radius of the circle?");
  208.             double radius = reader.nextDouble();
  209.             double circumference;
  210.             double area;
  211.             circumference = 2 * 3.14 * radius;
  212.             area = 3.14 * radius * radius;
  213.             System.out.println("Radius = " + radius + " Equation for circumference: 2 * 3.14 * " + radius);
  214.             System.out.println("Radius = " + radius + " Equation for area: 3.14 * " + radius + " * " + radius);
  215.             System.out.println("Here is the circumference of the circle: " + circumference);
  216.             System.out.println("Here is the area of the circle: " + area);
  217.         }
  218.     }
  219.  
  220.     public static void normalCalculator() {
  221.         Scanner reader = new Scanner(System.in);
  222.  
  223.         System.out.println(Colors.RED + "Welcome to the normal calculator" + Colors.RESET);
  224.         System.out.println(Colors.RED + "Type any equation into the line below" + Colors.RESET);
  225.         System.out.println(Colors.BLUE + "Do you want to add, subtract, mutliply, or divide");
  226.  
  227.         System.out.print(Colors.GREEN + "> " + Colors.RESET);
  228.         String input = reader.nextLine();
  229.  
  230.         if (input.equals("add")) {
  231.             System.out.println(Colors.BLUE + "Now type the first number you want to add");
  232.             double input1 = reader.nextDouble();
  233.  
  234.             System.out.println(Colors.BLUE + "Now type the second number you wan to add");
  235.             double input2 = reader.nextDouble();
  236.  
  237.             double inputTotal = input1 + input2;
  238.  
  239.             System.out.println("Your number is: " + inputTotal);
  240.             normalCalculator();
  241.         }
  242.         if (input.equals("subtract")) {
  243.             System.out.println(Colors.BLUE + "Now type the first number you want to subtract");
  244.             double input1 = reader.nextDouble();
  245.  
  246.             System.out.println(Colors.BLUE + "Now type the second number you wan to subtract");
  247.             double input2 = reader.nextDouble();
  248.  
  249.             double inputTotal = input1 - input2;
  250.  
  251.             System.out.println("Your number is: " + inputTotal);
  252.             normalCalculator();
  253.         }
  254.         if (input.equals("multiply")) {
  255.             System.out.println(Colors.BLUE + "Now type the first number you want to multiply");
  256.             double input1 = reader.nextDouble();
  257.  
  258.             System.out.println(Colors.BLUE + "Now type the second number you wan to multiply");
  259.             double input2 = reader.nextDouble();
  260.  
  261.             double inputTotal = input1 * input2;
  262.  
  263.             System.out.println("Your number is: " + inputTotal);
  264.             normalCalculator();
  265.         }
  266.         if (input.equals("divide")) {
  267.             System.out.println(Colors.BLUE + "Now type the first number you want to divide");
  268.             double input1 = reader.nextDouble();
  269.  
  270.             System.out.println(Colors.BLUE + "Now type the second number you wan to divide");
  271.             double input2 = reader.nextDouble();
  272.  
  273.             double inputTotal = input1 / input2;
  274.  
  275.             System.out.println("Your number is: " + inputTotal);
  276.             normalCalculator();
  277.         }
  278.     }
  279. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement