package Kuroware;
import java.util.Scanner;
public class KuroNote {
public static void main(String[] args) {
System.out.println("---------------------------------------------------------------");
System.out.println("Welcome, This is KuroNote!");
System.out.println("---------------------------------------------------------------");
//Initialize Variables
Scanner input = new Scanner(System.in);
boolean shouldWeLoop;
//Run Table Of Contents Method, Then loop until user hits exits ('N' or 'n')
do {
char shouldUserReturn = 'Y';
shouldWeLoop = tableOfContents(input, shouldUserReturn);
for (int i = 0; i < 100; ++i) System.out.println();
}
while (shouldWeLoop);
}
private static boolean tableOfContents(Scanner input, char shouldUserReturn) {
//PRINT TABLE OF CONTENTS
if (shouldUserReturn != 'n' || shouldUserReturn != 'N') {
System.out.println("TABLE OF CONTENTS");
System.out.println("---------------------------------------------------------------");
System.out.println("Chapter 0: IDE & General Information");
System.out.println(" [0.1] Projected Learning Path");
System.out.println(" [0.2] Short Cuts");
System.out.println(" [0.3] Glossary");
System.out.println(" [0.4] Unicode");
System.out.println(" [0.5] GameMaker");
System.out.println(" [0.6] Git/GitHub");
System.out.println(" [0.7] Intellij Create .jar & .bat files");
System.out.println(" [0.8] Naming Conventions");
System.out.println(" [0.9] Comments");
System.out.println("Chapter 1: Java Core Fundamentals");
System.out.println(" [1.1] Primitive Type (Domain, Range & Memory)");
System.out.println(" [1.2] Remainder Operator (%)");
System.out.println(" [1.3] Casting Types");
System.out.println(" [1.4] Parse Strings");
System.out.println(" [1.5] Scanner (Console input)");
System.out.println(" [1.6] Escape Sequences");
System.out.println(" [1.7] Math.Random ");
System.out.println("Chapter 2: Expressions, Statements and Methods");
System.out.println(" [2.1] While, For & Do");
System.out.println(" [2.2] Switch Statement");
System.out.println(" [2.3] Method Overloading");
System.out.println(" [2.4] Specific Method Examples");
System.out.println(" (a) DigitSum");
System.out.println(" (b) Prime Numbers");
System.out.println(" (c) Palindrome");
System.out.println(" (d) DaysInMonth");
System.out.println(" (e) etc.");
System.out.println(" [2.5] Drawing complex figures with static methods");
System.out.println("Chapter 3: Object Oriented Programming");
System.out.println(" [3.1] Classes");
System.out.println(" [3.2] Class Vs Instance Vs Object Vs Reference");
System.out.println(" [3.3] Getters & Setters");
System.out.println(" [3.4] Constructors");
System.out.println(" [3.5] This Vs Super");
System.out.println(" [3.6] Method Overriding");
System.out.println(" [3.7] Inheritance");
System.out.println(" [3.8] Static Vs Instance, Methods & Variables");
System.out.println("Chapter 4: Array, Java inbuilt Lists, Auto/Unboxing");
System.out.println(" [4.1] Array (1D)");
System.out.println(" [4.2] Array (2D)");
//RECORD USER INPUT
System.out.println("---------------------------------------------------------------");
System.out.println("[Chapter.Section] Enter Index Number = ");
System.out.println("---------------------------------------------------------------");
double userNumber = 0;
if (input.hasNextDouble()) {
userNumber = input.nextDouble();
}
//lOAD SECTION
callSection(userNumber);
//CHECK IF USER WANTS TO LOOP && RETURN VALUE FOR "shouldWeLoop"
shouldUserReturn = input.next().charAt(0);
if (shouldUserReturn == 'n') {
return false;
} else if (shouldUserReturn == 'N') {
return false;
} else {
return true;
}
} else {
return false;
}
}
//Calls the chapter methods
private static void callSection(double userNumber) {
//Load the Title
loadTitle(userNumber);
//Load the Section
if (userNumber == 0.1) {
section0_1();
} else if (userNumber == 0.2) {
section0_2();
} else if (userNumber == 0.3) {
section0_3();
} else if (userNumber == 0.4) {
section0_4();
} else if (userNumber == 0.5) {
section0_5();
} else if (userNumber == 0.6) {
section0_6();
} else if (userNumber == 0.7) {
section0_7();
} else if (userNumber == 0.8) {
section0_8();
} else if (userNumber == 0.9) {
section0_9();
} else if (userNumber == 1.1) {
section1_1();
} else if (userNumber == 1.2) {
section1_2();
} else if (userNumber == 1.3) {
section1_3();
} else if (userNumber == 1.4) {
section1_4();
} else if (userNumber == 1.5) {
section1_5();
} else if (userNumber == 1.6) {
section1_6();
} else if (userNumber == 1.7) {
section1_7();
} else if (userNumber == 1.8) {
section1_8();
} else if (userNumber == 2.1) {
section2_1();
} else if (userNumber == 2.2) {
section2_2();
} else if (userNumber == 2.3) {
section2_3();
} else if (userNumber == 2.4) {
section2_4();
}else if (userNumber == 2.5) {
section2_5();
} else if (userNumber == 3.1) {
section3_1();
} else if (userNumber == 3.2) {
section3_2();
} else if (userNumber == 3.3) {
section3_3();
} else if (userNumber == 3.4) {
section3_4();
} else if (userNumber == 3.5) {
section3_5();
} else if (userNumber == 3.6) {
section3_6();
} else if (userNumber == 3.7) {
section3_7();
} else if (userNumber == 4.1) {
section4_1();
} else if (userNumber == 4.2) {
section4_2();
} else {
System.out.println("Try choosing a listed number next time...");
}
//Escape suggestion
System.out.println("---------------------------------------------------------------");
System.out.println("[Any Key] RETURN TO TABLE OF CONTENTS\n" +
"[N] EXIT");
System.out.println("---------------------------------------------------------------");
//ALTERNATIVE METHOD
// int userNumberInt = (int) (10*userNumber);
// switch(userNumberInt){
// //Chapter 0:
// case 01:
// section0_1();
// break;
// case 02:
// section0_2();
// break;
// case 03:
// section0_3();
// break;
// case 04:
// section0_4();
// break;
// case 05:
// section0_5();
// break;
//
// case 06:
// section0_6();
// break;
// case 07:
// section0_7();
// break;
// case 08:
// section0_8();
// break;
//
// }
}
//Load Title "CHAPTER X, SECTION X : XXX"
public static void loadTitle(double userNumber) {
int chapterNumber = (int) userNumber;
int sectionNumber = (int) ((userNumber * 10) % 10);
System.out.println("---------------------------------------------------------------");
System.out.println("---------------------------------------------------------------");
System.out.println("CHAPTER " + chapterNumber + " SECTION " + sectionNumber);
System.out.println("---------------------------------------------------------------");
}
//CHAPTER 0
public static void section0_1() {
System.out.println("Projected Learning Path");
System.out.println("---------------------------------------------------------------");
System.out.println("#1. Java Core Skills");
System.out.println("#2. OOP (Object Oriented Programming)");
System.out.println("#3. Generics, Interfaces, abstract classes, Lambda Expressions, Collections, Multithreading, Etc.");
System.out.println("#4. SQL (Structured Query Language)");
System.out.println("#5. Spring Framework + Boot2");
System.out.println("#6. Docker (System Configurations)");
System.out.println("#7. Basics of Linux Commands");
System.out.println("#8. Basics of HTML/CSS/JS (Hyper Text Markup Language/Cascading Style Sheet/JavaScript)");
System.out.println("--------------------TYPICAL MINIMUM TIME REQUIRED---------------------");
System.out.println("#1-2: 4-6 Months");
System.out.println(" #3 : 2-3 Months");
System.out.println("#4-5: 3-4 Months");
System.out.println("#6-7: 1 Month");
System.out.println(" #8 : 1 Month");
System.out.println("Total Typical Time = 11-15 Months");
System.out.println("---------------------ACTUAL TIME SPENT------------------------");
System.out.println("#1: 10/18/19 - 02/11/20");
System.out.println("#2: 02/11/20 - 04/08/20");
System.out.println("#3: 04/08/20 - xx/xx/xx");
}
public static void section0_2() {
System.out.println("SHORT CUTS!");
System.out.println("-------------Intellij IDE [Favorites]----");
System.out.println("[Ctrl] + [Shift] + [F10] = Run Program");
System.out.println("[CTRL] + [SHIFT] + [ALT] + [S] = Project Structure");
System.out.println("[CTRL] + [F9] = Rebuild Project");
System.out.println("[CTRL] + [K] = GitHub Commit Window ");
System.out.println("[CTRL] + [SHIFT] + [K] = GitHub Push Window");
System.out.println("[CTRL] + [\"[\"] = Go to Beginning of Code Block");
System.out.println("[CTRL] + [\"]\"] = Go to End of Code Block");
System.out.println("[Ctrl] + [Shift] + [NumPad+] = Expand all");
System.out.println("[Ctrl] + [Shift] + [NumPad-] = Collapse all");
System.out.println("-------------Eclipse IDE [Favorites]----");
System.out.println("[Ctrl] + [F11] = Run Program");
System.out.println("-------------Intellij IDE---------------");
System.out.println("Double [Shift] = Search Everywhere");
System.out.println("[Ctrl] + [Shift] + [A] = Find Action");
System.out.println("Double [Ctrl] = Run Anything");
System.out.println("[Ctrl ] + [/] = Comment/Uncomment a line");
System.out.println("[Ctrl ] + [C] = Select Entire Line");
System.out.println("[Ctrl ] + [Shift] + [Left & Right Arrow Keys] = Move Cursor Quickly Whilst Selecting");
System.out.println("[Ctrl ] + [Shift] + [Up & Down Arrow Keys] = Move Current Line Position");
System.out.println("[Ctrl] + [Delete] = Delete Until Word End");
System.out.println("[Ctrl] + [Backspace] = Delete Until Word Start");
System.out.println("[\"sout\"] + [ENTER] = System.out.println();");
System.out.println("[F12] = Select Run window");
System.out.println("[F2] + [Shift] = F2Navigate between code issues");
System.out.println("[Alt] + [Enter] = Show intention actions and quick-fixes");
System.out.println("[Ctrl] + [E] = View recent files");
System.out.println("[Ctrl] + [Shift] + [Enter] = Complete current statement");
System.out.println("[Ctrl] + [Alt] + [L] = Reformat code");
System.out.println("[Ctrl] + [Shift] + [Alt] + [T] = Invoke refactoring");
System.out.println("[Ctrl] + [W] = Extend or shrink selection");
System.out.println("[Ctrl] + [Shift] + [W] = Increase or decrease the scope of selection according to specific code constructs.");
System.out.println("[Ctrl] + [B] = Go to declaration");
System.out.println("[Alt] + [F7] = Find usages");
System.out.println("[Alt] + [1] = Focus the Project tool window");
System.out.println("[Escape] = Focus the editor");
System.out.println("-------------Good To Know---------------");
System.out.println("[Ctrl] + [Shift] + [U] = Toggle Upper & Lower Case");
System.out.println("[Ctrl] + [Shift] + [/] = Comment/Uncomment a block of code");
System.out.println("[Ctrl] + [Y] = To delete a line (Or Redo depending on setting)");
System.out.println("[SHIFT] + [DELETE] = [Delete behaves as backspace]");
}
public static void section0_3() { //Make Pages for this like 1/3 2/3 3/3 and put it in a while loop to contain forward,back,exit options
System.out.println("Java Language and Terminology");
System.out.println("---------------------------------------------------------------");
System.out.println("Every executable Java program consists of a class,–that contains a method named main,•that contains the statements (commands) to be executed");
System.out.println("");
/*
System.out.println("In this article, we’ll explore the foundations and core concepts of the Java language and terminology.\n" +
"\n" +
"The write-up is divided into sections, ordered alphabetically to enable fast and easy search for these definitions.\n" +
"\n" +
"A\n" +
"abstract – a keyword used in a class or method definition, which specifies that the method/class is not going to be instantiated, but should be inherited by other methods or classes:\n" +
"\n" +
"public abstract class Foo {\n" +
" abstract void runFoo();\n" +
"}\n" +
"API (Application Programming Interface) – is the way to expose a set of pre-defined classes and interfaces to external clients to interact with them, without sharing the implementation details\n" +
"\n" +
"argument – an input specified in a method call; it can be a literal value, a variable, or an expression:\n" +
"\n" +
"void fooMethod(int argument1);\n" +
"array – a fixed-size collection of data of the same type, which can hold zero or more items:\n" +
"\n" +
"int[] array = new int[16];\n" +
"autoboxing – automatic conversion between the primitive types and their corresponding object wrapper classes:\n" +
"\n" +
"Character a = 'a';\n" +
"B\n" +
"block – code between two matching open and close braces, which is the single logical unit of work inside the application:\n" +
"\n" +
"{ some code }\n" +
"\n" +
"boolean – a primitive type, holding only two values – true or false:\n" +
"\n" +
"boolean condition = false;\n" +
"break – a statement used to exit a loop/switch statement/labeled block; the application continues execution with the statement immediately following the containing block:\n" +
"\n" +
"int hour = 8;\n" +
"switch (hour) {\n" +
" case 8:\n" +
" //some code\n" +
" break;\n" +
" default:\n" +
" //some code\n" +
" break;\n" +
"}\n" +
"byte – a primitive type of the size of eight bits:\n" +
"\n" +
"byte b = 100;\n" +
"bytecode – the instruction set for Java Virtual Machine, created from source files into bytecode by the compiler\n" +
"\n" +
"C\n" +
"case – a keyword that defines a particular group of statements executed in a switch statement:\n" +
"\n" +
"int hour = 8;\n" +
"switch (hour) {\n" +
" case 8:\n" +
" //some code\n" +
" break;\n" +
" default:\n" +
" //some code\n" +
" break;\n" +
"}\n" +
"casting – conversion from one data type to another:\n" +
"\n" +
"Object o = \"test\";\n" +
"String str = (String) o;\n" +
"catch – the block of code inside try/catch statement, responsible for handling exceptions:\n" +
"\n" +
"try {\n" +
" // code\n" +
"} catch (Exception e) {\n" +
" // exception handling\n" +
"}\n" +
"char – a keyword used to declare a variable of single type character:\n" +
"\n" +
"char a = 'a';\n" +
"checked exception – an Exception that is caught at the compilation time, usually in the block or thrown in the method header\n" +
"\n" +
"class – the core type in Java that defines the implementation of a particular kind of object; it defines instance and class variables and methods, as well as specifies the interfaces it implements and the immediate superclass of the class, by default Object:\n" +
"\n" +
"public class Foo {}\n" +
"class method – a synonym of static class\n" +
"\n" +
"class variable – a synonym of a static field or a static variable\n" +
"\n" +
"classpath – an environment variable or a command-line argument indicating the path searched by the Java compiler and the runtime for class definitions\n" +
"\n" +
"comment – a piece of explanatory text ignored by the compiler:\n" +
"\n" +
"// first comment\n" +
"/* comment block \n" +
"/** documentation ;
compiler – a program used to translate source code into the code executed by a computer\n" +
"\n" +
"concurrency – it is the ability of a program to run several tasks in parallel, a primary feature of multithreading\n" +
"\n" +
"condition – a boolean expression controlling a conditional statement or loop:\n" +
"\n" +
"if (condition) {}\n" +
"constant – a final variable in Java, which means that the reference of it cannot be changed once initialized:\n" +
"\n" +
"final int number = 20;\n" +
"constructor – a method inside the class, which creates and initializes objects in it – needs to be public and names the same as the class:\n" +
"\n" +
"public class Foo {\n" +
" public Foo(){}; // constructor\n" +
"}\n" +
"continue – a keyword used to resume application execution at the end of the current loop:\n" +
"\n" +
"for (int i=1; i<10; i++){\n" +
" for (int j=1; j<10; j++){\n" +
" if (condition) continue;\n" +
" }\n" +
"}\n" +
"curly brackets – please refer to block\n" +
"\n" +
"D\n" +
"declaration – officially, this is defined as a statement that establishes an identifier and associates attributes with it, without necessarily reserving its storage or providing the implementation\n" +
"\n" +
"default – the optional destination used in a switch statement, when neither case statement matches the requested behavior:\n" +
"\n" +
"int hour = 8;\n" +
"switch (hour) {\n" +
" case 8:\n" +
" //some code\n" +
" break;\n" +
" default:\n" +
" //some code\n" +
" break;\n" +
"}\n" +
"definition – a declaration that reserves storage (for data) or provides an implementation (for methods)\n" +
"\n" +
"deprecation – a class/method/interface that has been made obsolete by later versions of the library or of the language itself; it should not be used as there is no guarantee that it will exist in future versions\n" +
"\n" +
"direct recursion – a recursion that starts in the stack of the calling method itself\n" +
"\n" +
"do – a keyword used to declare a while loop ensuring execution of the first iteration of the loop before the check of the boolean condition:\n" +
"\n" +
"do {\n" +
" // code\n" +
"} while (expression);\n" +
"DOM – Document Object Model, defined by the W3C, that allows applications to dynamically access and update the content, structure, and style of documents\n" +
"\n" +
"downcast – a process of changing the data type from Object to the particular type, i.e., Integer:\n" +
"\n" +
"Object o = 10;\n" +
"Integer num = (Integer) o;\n" +
"double – a Java primitive type of the type double:\n" +
"\n" +
"double lat = 52.11\n" +
"E\n" +
"else – a keyword used in if/else condition statements, executed when the test condition is false:\n" +
"\n" +
"if (condition) {\n" +
" // code\n" +
"} else {\n" +
" // code\n" +
"}\n" +
"encapsulation – the process of protecting the state of objects by defining its attributes as private and channeling access to them through accessor and mutator methods\n" +
"\n" +
"enum – a Java keyword used to declare the enumerated type (whose values are a fixed set of constants):\n" +
"\n" +
"public enum Day {\n" +
" SUNDAY, MONDAY, TUESDAY, WEDNESDAY,\n" +
" THURSDAY, FRIDAY, SATURDAY \n" +
"}\n" +
"exception – an exceptional circumstance preventing the program to continue working regularly (usually an error or bug); here are some best practices to deal with and further understand exceptions in Java\n" +
"\n" +
"expression – a combination of operands and operators which causes particular behavior and produces results\n" +
"\n" +
"extends – a keyword used to define the inheritance of classes or interfaces:\n" +
"\n" +
"public class Foo extends FooMother {}\n" +
"F\n" +
"field – a variable defined outside of all defined methods, but inside of the class; in other words, a member of a class\n" +
"\n" +
"final – a Java keyword indicating that an entity is immutable, thus, you can’t change its reference during the program execution:\n" +
"\n" +
"final int number = 20;\n" +
"finally – a block in a try/catch statement executed even Java exception or runtime error occurred:\n" +
"\n" +
"try {\n" +
" // code\n" +
"} catch (Exception e) {\n" +
" // exception handling\n" +
"} finally {\n" +
" // code to be executed at the end\n" +
"float – a Java keyword used to define a floating point number variable:\n" +
"\n" +
"float cash = 24.5;\n" +
"for – a Java control structure used for loop execution:\n" +
"\n" +
"for (int i=0; i<10; i++){\n" +
" // code\n" +
"}\n" +
"G\n" +
"garbage collection – the process by which the JVM automatically frees up unused memory; to go further into the GC process and potential problems in that process, you can read the deep-dive into memory leaks here\n" +
"\n" +
"global variable – a variable that is visible to all methods in the class\n" +
"\n" +
"GUI – graphical user interface\n" +
"\n" +
"H\n" +
"hash code – a value used to provide an efficient way to map object and its location, returned by a hash function\n" +
"\n" +
"hash function – a method used to produce hash code from any data of arbitrary size to data of fixed size\n" +
"\n" +
"hexadecimal – a number represented by the base of 16\n" +
"\n" +
"HTML – HyperText Markup Language; a web content presentation language\n" +
"\n" +
"HTTP(S) – HyperText Transfer Protocol (Secure); a protocol that defines all rules how the browser should communicate with a server\n" +
"\n" +
"I\n" +
"identifier – a name of a class, variable, method or interface defined in the code by the software developer:\n" +
"\n" +
"String identifier = \"Some string\";\n" +
"if – a Java control structure used to choose if execution of further actions should continue or not:\n" +
"\n" +
"if (condition) {\n" +
" // code\n" +
"} else {\n" +
" // code\n" +
"}\n" +
"immutable object – an object whose state or value is not changeable after creation\n" +
"\n" +
"implements – a Java keyword used to indicate which interfaces are implemented by the current class:\n" +
"\n" +
"public class Foo implements Foo {\n" +
" // implementation of all methods defined in the Foo interface\n" +
"}\n" +
"import – a statement used to enable the use of other classes or interfaces from different Java packages:\n" +
"\n" +
"import java.util.*;\n" +
"indirect recursion – a recursion that happens when method A calls method B while a call from the method B to the method A is still in progress\n" +
"\n" +
"infinite recursion – a recursion that can technically continue indefinitely; it very often indicates a logic error and can lead to StackOverflow errors\n" +
"\n" +
"inheritance – a feature of object-oriented programming, where classes contain all variables and methods defined in their supertypes\n" +
"\n" +
"int – a Java primitive of the type integer:\n" +
"\n" +
"int number = 10;\n" +
"interface – a Java keyword used to define the collection of methods and constant values that can be furthermore implemented by other classes:\n" +
"\n" +
"public interface IFoo {\n" +
" void start();\n" +
" void stop();\n" +
" int restart();\n" +
"}\n" +
"iteration – a single execution of a loop\n" +
"\n" +
"J\n" +
"JAR – Java Archive is the default Java packaging mechanism to aggregate multiple files into one (similar to .zip)\n" +
"\n" +
"Java Core – provides the main features of Java, also named Java Standard Edition\n" +
"\n" +
"Java EE – Java Enterprise Edition\n" +
"\n" +
"JDK – Java Development Kit, the environment and core libraries used to write Java programs\n" +
"\n" +
"JVM – Java Virtual Machine, the abstract machine where the compiled Java bytecode is executed\n" +
"\n" +
"L\n" +
"livelock – a situation when two separate threads are waiting for each other to check the condition of particular part of the program\n" +
"\n" +
"local variable – a variable defined in the method body, visible only inside it\n" +
"\n" +
"long – a Java primitive of the type long:\n" +
"\n" +
"long bigNumber = 100L;\n" +
"M\n" +
"main method – a starting point for Java applications:\n" +
"\n" +
"public static void main(String[] args){}\n" +
"memory leak – a situation during the program execution where memory that is no longer being used cannot be removed by the garbage collector as there is still a reference to it; it eventually leads to OutOfMemoryException\n" +
"\n" +
"method – a particular function implemented in a Java class:\n" +
"\n" +
"public int doSthAndReturnInt();\n" +
"module – a group of program components; in Java, the term that’s used for it is package\n" +
"\n" +
"multithreaded – a program capable of concurrent execution on multiple threads\n" +
"\n" +
"mutual recursion – this happens when two methods are calling each other recursively at the same time\n" +
"\n" +
"N\n" +
"namespace – an area of the program defined by packages, with established certain visibility rules (e.g. private access, public access, etc.)\n" +
"\n" +
"native – a keyword indicating that particular method is not implemented in Java language itself, but in another programming language\n" +
"\n" +
"nested class – a class, which is implemented inside the body of the other class\n" +
"\n" +
"new – the operator used to create an instance of a class\n" +
"\n" +
"null – a type indicating that object reference variable has no reference to any object existing in memory\n" +
"\n" +
"O\n" +
"object – an instance of a particular class; also the core concept of the OOP\n" +
"\n" +
"OOP – Object Oriented Programming – a primary paradigm in modern software development, focused on objects as primitives, not the specific actions; each object is created/instantiated from a class\n" +
"\n" +
"operator – a symbol used for arithmetic or boolean expressions, e.g. +,-,/,*,=\n" +
"\n" +
"operator precedence – the order of processing conditions or equations with the multiple operators, similar to the mathematical concept of order of operations\n" +
"\n" +
"overloading – using the same method name for various implementation, differentiated by parameters:\n" +
"\n" +
"private int sum(int x, int y) {\n" +
" return (x + y);\n" +
"}\n" +
" \n" +
"private int sum(int x, int y, int z) { \n" +
" return (x + y + z);\n" +
"}\n" +
"overriding – providing a different implementation of the original method in its subclass:\n" +
"\n" +
"public class Foo {\n" +
" public void test(){\n" +
" // original implementation\n" +
" }\n" +
"}\n" +
"\n" +
"public class BabyFoo extends Foo {\n" +
" @Override\n" +
" public void test(){\n" +
" // overriden implementation\n" +
" }\n" +
"}\n" +
"P\n" +
"package – a name for a grouping of classes and interfaces in a namespace\n" +
"\n" +
"primitive type – one of the following non-class variable type: boolean, byte, char, double, float, int, long or short\n" +
"\n" +
"private – a Java modifier, used to specify the visibility of a method or a variable, so they can be accessed only within its class\n" +
"\n" +
"protected – another modifier that makes variables or classes accessible to all other elements in the same package\n" +
"\n" +
"public – a modifier allowing external access to a particular variable or method\n" +
"\n" +
"R\n" +
"recursion – a process where a method is invoked again from its existing call stack\n" +
"\n" +
"reflection – the ability of the code to inspect and manipulate other code in the same runtime process\n" +
"\n" +
"return – a Java keyword used to finish the execution of the method and return data back to the caller\n" +
"\n" +
"S\n" +
"scope – it determines the visibility of elements in the program, for example, local or global variables\n" +
"\n" +
"serialization – the process of encoding and decoding the objects to the stream of bytes, and vice-versa\n" +
"\n" +
"short – a keyword used to specify the variable of the type short:\n" +
"\n" +
"short num = 2;\n" +
"static – class member variable stored and accessed as a single instance for all objects of that class:\n" +
"\n" +
"public static class Foo {\n" +
" public static int num = 10;\n" +
" public static void useMe(){\n" +
" // code\n" +
" }\n" +
"}\n" +
"stream – a byte-stream of data sent from sender to receiver\n" +
"\n" +
"String – an instance of an immutable String class, containing zero or more Unicode characters:\n" +
"\n" +
"String myText = \"Hello... It's me.\";\n" +
"super – a keyword allowing the access to members of a class inherited by the class in which it appears\n" +
"\n" +
"switch – a control structure with multiple cases:\n" +
"int hour = 8;\n" +
"switch (hour) {\n" +
" case 8:\n" +
" //some code\n" +
" break;\n" +
" default:\n" +
" //some code\n" +
" break;\n" +
"}\n" +
"synchronized – a control statement that guarantees single-access semantics in a multithreaded environment\n" +
"\n" +
"T\n" +
"this – a statement that references the instance of the class where it appears\n" +
"\n" +
"thread – a basic, single lightweight execution process supported natively by the JVM as well as by the OS\n" +
"\n" +
"throw – a statement used to throw an Exception:\n" +
"\n" +
"void dontUseThisMethod(){\n" +
" throw Exception;\n" +
"}\n" +
"throws – a keyword in a method header indicating that one or more exceptions will be propagated from this method:\n" +
"\n" +
"public void startEngine() throws IOException;\n" +
"try – a block of code that allows exceptions to be caught using a catch block:\n" +
"\n" +
"try {\n" +
" // code\n" +
"} catch (Exception e) {\n" +
" // exception handling\n" +
"} finally {\n" +
" // code to be executed at the end\n" +
"U\n" +
"unchecked exception – an error without handler defined in the program implementation, cannot be dealt with at compilation time\n" +
"\n" +
"Unicode – a 16-bit character set defined by ISO 10646, designed to make exchange and display of information easier across various languages\n" +
"\n" +
"URI, URL – Uniform Resource Identifier/Locator. You can read more about the difference between these two concepts here\n" +
"\n" +
"upcast – a process of casting to super type – for example from String to Object:\n" +
"\n" +
"String text = \"Test\";\n" +
"Object o = (Object) o;\n" +
"V\n" +
"variable – an item of data associated with a specific type\n" +
"\n" +
"variable declaration – the place in the application, where the specific variable is assigned to one of the existing Java types\n" +
"\n" +
"virtual machine – see JVM\n" +
"\n" +
"void – a keyword used to indicate that method does not return any value\n" +
"\n" +
"volatile – a modifier specifying how the variable behaves in a multithreaded environment; the variable will never be cached in a thread-local – as it’s expected to be modified by different threads\n" +
"\n" +
"W\n" +
"while – a Java control structure used for looping:\n" +
"\n" +
"while (condition) {\n" +
" // code\n" +
"}\n" +
"wrapper – an object that encapsulates primitive types into one of the classes from the java.lang package: Boolean, Byte, Character, Double, Float, Integer, Long or Short to provide additional methods\n");
*/
System.out.println("PAGES ARE IN DEVELOPMENT, COMING SOON!");
}
public static void section0_4() {
System.out.println("Unicode");
System.out.println("---------------------------------------------------------------");
System.out.println("----------Superscripts----------");
System.out.println("⁰ \tU+2070 (alt-08304)\tSUPERSCRIPT ZERO\n" +
"ⁱ \tU+2071 (alt-08305)\tSUPERSCRIPT LATIN SMALL LETTER I\n" +
"⁴ \tU+2074 (alt-08308)\tSUPERSCRIPT FOUR\n" +
"⁵ \tU+2075 (alt-08309)\tSUPERSCRIPT FIVE\n" +
"⁶ \tU+2076 (alt-08310)\tSUPERSCRIPT SIX\n" +
"⁷ \tU+2077 (alt-08311)\tSUPERSCRIPT SEVEN\n" +
"⁸ \tU+2078 (alt-08312)\tSUPERSCRIPT EIGHT\n" +
"⁹ \tU+2079 (alt-08313)\tSUPERSCRIPT NINE\n" +
"⁺ \tU+207A (alt-08314)\tSUPERSCRIPT PLUS SIGN\n" +
"⁻ \tU+207B (alt-08315)\tSUPERSCRIPT MINUS\n" +
"⁼ \tU+207C (alt-08316)\tSUPERSCRIPT EQUALS SIGN\n" +
"⁽ \tU+207D (alt-08317)\tSUPERSCRIPT LEFT PARENTHESIS\n" +
"⁾ \tU+207E (alt-08318)\tSUPERSCRIPT RIGHT PARENTHESIS\n" +
"ⁿ \tU+207F (alt-08319)\tSUPERSCRIPT LATIN SMALL LETTER N\n");
System.out.println("----------Subscripts----------");
System.out.println("₀ \tU+2080 (alt-08320)\tSUBSCRIPT ZERO\n" +
"₁ \tU+2081 (alt-08321)\tSUBSCRIPT ONE\n" +
"₂ \tU+2082 (alt-08322)\tSUBSCRIPT TWO\n" +
"₃ \tU+2083 (alt-08323)\tSUBSCRIPT THREE\n" +
"₄ \tU+2084 (alt-08324)\tSUBSCRIPT FOUR\n" +
"₅ \tU+2085 (alt-08325)\tSUBSCRIPT FIVE\n" +
"₆ \tU+2086 (alt-08326)\tSUBSCRIPT SIX\n" +
"₇ \tU+2087 (alt-08327)\tSUBSCRIPT SEVEN\n" +
"₈ \tU+2088 (alt-08328)\tSUBSCRIPT EIGHT\n" +
"₉ \tU+2089 (alt-08329)\tSUBSCRIPT NINE\n" +
"₊ \tU+208A (alt-08330)\tSUBSCRIPT PLUS SIGN\n" +
"₋ \tU+208B (alt-08331)\tSUBSCRIPT MINUS\n" +
"₌ \tU+208C (alt-08332)\tSUBSCRIPT EQUALS SIGN\n" +
"₍ \tU+208D (alt-08333)\tSUBSCRIPT LEFT PARENTHESIS\n" +
"₎ \tU+208E (alt-08334)\tSUBSCRIPT RIGHT PARENTHESIS\n");
System.out.println("----------<<>>----------");
System.out.println("public class Main {\n" +
"\n" +
" public static void main(String[] args) {\n" +
" char myChar = 'D';\n" +
" char myUnicodeChar = '\\u0044';\n" +
"\t//Both are just D!\n" +
" System.out.println(myChar);\n" +
" System.out.println(myUnicodeChar);\n" +
"\n" +
"\t//Don't forget use CC! =]\n" +
" char myCopyrightChar = '\\u00A9';\n" +
" System.out.println(myCopyrightChar);\n" +
"}");
System.out.println("----------Favorites----------");
System.out.println("φ \tU+03C6 (alt-0966)\tGREEK SMALL LETTER PHI\n" +
"∞ \tU+221E (alt-08734)\tINFINITY\n" +
"Δ \tU+0394 (alt-0916)\tGREEK CAPITAL LETTER DELTA\n" +
"Σ \tU+03A3 (alt-0931)\tGREEK CAPITAL LETTER SIGMA\n" +
"∫ \tU+222B (alt-08747)\tINTEGRAL\n" +
"π \tU+03C0 (alt-0960)\tGREEK SMALL LETTER PI\n" +
"≅ \tU+2245 (alt-08773)\tAPPROXIMATELY EQUAL TO\n" +
"≆ \tU+2246 (alt-08774)\tAPPROXIMATELY BUT NOT ACTUALLY EQUAL TO\n" +
"≇ \tU+2247 (alt-08775)\tNEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO\n" +
"≈ \tU+2248 (alt-08776)\tALMOST EQUAL TO = asymptotic to\n" +
"∓ \tU+2213 (alt-08723)\tMINUS-OR-PLUS SIGN\n" +
"√ \tU+221A (alt-08730)\tSQUARE ROOT = radical sign\n" +
"∛ \tU+221B (alt-08731)\tCUBE ROOT\n" +
"∜ \tU+221C (alt-08732)\tFOURTH ROOT\n" +
"∝ \tU+221D (alt-08733)\tPROPORTIONAL TO\n" +
"μ \tU+03BC (alt-0956)\tGREEK SMALL LETTER MU\n" +
"χ \tU+03C7 (alt-0967)\tGREEK SMALL LETTER CHI\n" +
"α \tU+03B1 (alt-0945)\tGREEK SMALL LETTER ALPHA\n" +
"β \tU+03B2 (alt-0946)\tGREEK SMALL LETTER BETA" +
"ω \tU+03C9 (alt-0969)\tGREEK SMALL LETTER OMEGAΔ\n+" +
"Ω \tU+03A9 (alt-0937)\tGREEK CAPITAL LETTER OMEGA\n" +
"ψ \tU+03C8 (alt-0968)\tGREEK SMALL LETTER PSI\n" +
"Ψ \tU+03A8 (alt-0936)\tGREEK CAPITAL LETTER PSI\n" +
"∟ \tU+221F (alt-08735)\tRIGHT ANGLE\n" +
"∠ \tU+2220 (alt-08736)\tANGLE\n" +
"∡ \tU+2221 (alt-08737)\tMEASURED ANGLE\n" +
"∢ \tU+2222 (alt-08738)\tSPHERICAL ANGLE = angle arc\n");
}
public static void section0_5() {
System.out.println("GameMaker");
System.out.println("----------------------------------------");
System.out.println("HOT KEYS!!!");
System.out.println("CTRL + F = Open local search box");
System.out.println("CTRL + H = Open local search and replace box");
System.out.println("CTRL + K = Comment out the selected line (or lines) of text");
System.out.println("CTRL + SHIFT + K = Uncomment the selected line (or lines) of text");
System.out.println("----------------------------------------");
System.out.println("Object Spin with Arrow keys EX:" +
"\n");
System.out.println("if (keyboard_check(vk_left)){\n" +
"\t\timage_angle = image_angle +5;\n" +
"}\n" +
"\n" +
"if (keyboard_check(vk_right)){\n" +
"\t\timage_angle = image_angle -5;\n" +
"}");
System.out.println(" ");
}
public static void section0_6() {
System.out.println("Git & GitHub");
System.out.println("----------------------------------------");
System.out.println("GitHub (Intellij)");
System.out.println("SHORTCUTS");
System.out.println(" CTRL + K = Commit Window");
System.out.println(" CTRL + SHIFT + K = Push Window");
System.out.println("Share a project on GitHub");
System.out.println(" 1.\tOpen the project you want to share.\n" +
" 2.\tFrom the main menu, choose VCS | Import into Version Control | Share Project on GitHub.\n" +
" If you have already registered your GitHub account in IntelliJ IDEA, connection will be established using these credentials.\n" +
" If you have not registered your account in IntelliJ IDEA, the Login to GitHub dialog opens. Specify your access token or request a new one with your login and password.\n" +
" 3.\tWhen connection to GitHub has been established, the Share Project on GitHub dialog opens. Specify the new repository name, the name of the remote, and enter a description of your project.\n" +
" You can select the Private option if you do not want to allow public access to your repository for other GitHub users (note that this option is unavailable for free accounts).\n" +
" 4.\tClick Share to initiate a new repository and upload project sources to it.\n");
}
public static void section0_7() {
System.out.println("CREATE A JAR FILE WITH INTELLIJ IDEA (.jar)");
System.out.println("----------------------------------------");
System.out.println("SHORTCUTS");
System.out.println(" CTRL + SHIFT + ALT + S = Project Structure");
System.out.println(" CTRL + F9 = Rebuild Project");
System.out.println("\n");
System.out.println("STEPS TO CREATE .jar");
System.out.println("1. Project Structure");
System.out.println("2. Build Artifact...");
System.out.println("3. Locate In project (Out/artifacts/ProjectName_jar) \n\t Copy Path");
System.out.println("4. Open CMD \n\t Example: \"java -jar C:\\intellijCodeRepository\\Kennedy\\out\\artifacts\\Kennedy_jar\\Kennedy.jar\"");
System.out.println("\nCREATE A BAT FILE (.bat)");
System.out.println("1. Create Note (.txt)");
System.out.println("2. Edit and insert \n\t java -jar C:\\intellijCodeRepository\\Kennedy\\out\\artifacts\\Kennedy_jar\\Kennedy.jar");
System.out.println("3. Rename and change extension to .bat");
System.out.println("4. CREATE SHORTCUT! =]");
}
public static void section0_8() {
System.out.println("Naming Convention");
System.out.println("----------------------------------------");
System.out.println("PACKAGE NAMES");
System.out.println("1. Always lower case");
System.out.println("2. Packages should be unique");
System.out.println("3. Use your internet domain name, reversed, as a prefix for the package name.");
System.out.println("4. Can't start with a number");
System.out.println(" Examples:");
System.out.println(" A. Switch.suppliers.com -> com.supplier._switch");
System.out.println(" B. 1world.com -> com._1world");
System.out.println(" C. Expert-exchange.com -> com.experts_exchange");
System.out.println("----------------------");
System.out.println("CLASS NAMES");
System.out.println("1. CamelCase");
System.out.println("2. Must be unique");
System.out.println("3. Can't start with a number");
System.out.println(" Examples:");
System.out.println(" A. ArrayList");
System.out.println(" B. LinkedList");
System.out.println(" C. String");
System.out.println(" D. TopSong");
System.out.println(" E. GearBox");
System.out.println(" F. Main");
System.out.println("----------------------");
System.out.println("INTERFACE NAMES");
System.out.println("1. CamelCase");
System.out.println("2. Must be unique");
System.out.println("3. Can't start with a number");
System.out.println(" Examples:");
System.out.println(" A. List");
System.out.println(" B. Comparable");
System.out.println(" C. Serializable");
System.out.println("----------------------");
System.out.println("METHOD NAMES");
System.out.println("1. mixedCase");
System.out.println("2. often verbs");
System.out.println("3. should reflect the function preformed or the result returned");
System.out.println(" Examples:");
System.out.println(" A. size()");
System.out.println(" B. getName()");
System.out.println(" C. addPlayer()");
System.out.println("----------------------");
System.out.println("CONSTANTS NAMES");
System.out.println("1. ALL UPPER_CASE");
System.out.println("2. Separate words with an underscore _");
System.out.println("3. Declared using the \"final\" keyword");
System.out.println("4. Must be unique");
System.out.println(" Examples:");
System.out.println(" A. GRID_SIZE");
System.out.println(" B. MAX_INT");
System.out.println(" C. SEVERITY_ERROR");
System.out.println(" D. P1 (Used for Pi 3.141592653");
System.out.println("----------------------");
System.out.println("VARIABLE NAMES");
System.out.println(" 1. mixedCase");
System.out.println(" 2. meaningful and indicative");
System.out.println(" 3. Start with lower case letter");
System.out.println(" 4. do NOT use underscores _");
System.out.println(" Examples:");
System.out.println(" A. positionOfUnit");
System.out.println(" B. velocityOfUnit");
System.out.println(" C. accelerationOfUnit");
System.out.println("----------------------");
System.out.println("OPTIONALLY");
System.out.println("A name given to an item in your program must start with a letter or _ or $");
System.out.println(" Legal:");
System.out.println(" masterSword");
System.out.println(" MasterSword");
System.out.println(" MASTER_SWORD_4");
System.out.println(" $masterSword$");
System.out.println(" Illegal:");
System.out.println(" master+Sword");
System.out.println(" 4masterSword");
System.out.println(" master-Sword");
System.out.println(" master.Sword");
System.out.println(" masterSword's");
}
public static void section0_9() {
System.out.println("Comments");
System.out.println("----------------------------------------");
System.out.println("Where to place comments:");
System.out.println(" - at the top of each file (a \"comment header\")");
System.out.println(" - at the start of every method");
System.out.println(" - to explain complex pieces of code");
System.out.println("Comments are useful for:");
System.out.println(" - Understanding larger, more complex programs.");
System.out.println(" - Multiple programmers working together, who must understand each other's code.");
System.out.println("---EXAMPLE------------------------------");
System.out.println("// This is a one-line comment.");
System.out.println("/* This is a very long \nmulti-line comment. */");
}
//CHAPTER 1
public static void section1_1() {
System.out.println("Primitive Types");
System.out.println("---------------------------------------------------------------");
byte myMinByteValue = Byte.MIN_VALUE;
byte myMaxByteValue = Byte.MAX_VALUE;
System.out.println("Byte Minimum Value = " + myMinByteValue);
System.out.println("Byte Maximum Value = " + myMaxByteValue);
System.out.println("----------------------------------------");
short myMinShortValue = Short.MIN_VALUE;
short myMaxShortValue = Short.MAX_VALUE;
System.out.println("Short Minimum Value = " + myMinShortValue);
System.out.println("Short Maximum Value = " + myMaxShortValue);
System.out.println("----------------------------------------");
int myMinIntValue = Integer.MIN_VALUE;
int myMaxIntValue = Integer.MAX_VALUE;
System.out.println("Int Minimum Value = " + myMinIntValue);
System.out.println("Int Maximum Value = " + myMaxIntValue);
System.out.println("----------------------------------------");
long myMinLongValue = Long.MIN_VALUE;
long myMaxLongValue = Long.MAX_VALUE;
System.out.println("Long Minimum Value = " + myMinLongValue);
System.out.println("Long Maximum Value = " + myMaxLongValue);
System.out.println("----------------------------------------");
System.out.println("----------------------------------------");
float myMinFloatValue = Float.MIN_VALUE;
float myMaxFloatValue = Float.MAX_VALUE;
System.out.println("Float Minimum Value = " + myMinFloatValue);
System.out.println("Float Maximum Value = " + myMaxFloatValue);
System.out.println("----------------------------------------");
double myMinDoubleValue = Double.MIN_VALUE;
double myMaxDoubleValue = Double.MAX_VALUE;
System.out.println("Double Minimum Value = " + myMinDoubleValue);
System.out.println("Double Maximum Value = " + myMaxDoubleValue);
System.out.println("---------------------------------------------------------------");
System.out.println("Memory = XX (bit)");
System.out.println("---------------------------------------------------------------");
System.out.println("byte = 08 (bit)");
System.out.println("short = 16 (bit)");
System.out.println("int = 32 (bit)");
System.out.println("long = 64 (bit)");
System.out.println("float = 32 (bit)");
System.out.println("double = 64 (bit)");
System.out.println("---------------------------------------------------------------");
System.out.println("Examples");
System.out.println("---------------------------------------------------------------");
System.out.println("char [variableName] = 'A';");
System.out.println("boolean [variableName] = true;");
System.out.println("byte [variableName] = 120;");
System.out.println("short [variableName] = 30_000;");
System.out.println("int [variableName] = 2_000_000;");
System.out.println("long [variableName] = 3_000_000L;");
System.out.println("float [variableName] = 3.14F;");
System.out.println("double [variableName] = 6.18D; ");
}
public static void section1_2() {
System.out.println("CHAPTER 9 : Remainder Operator (%)");
System.out.println("----------------------------------------");
System.out.println("Obtain last Digit of a number:");
System.out.println(" 17026 % 10 = 6");
System.out.println("Obtain last 4 Digits of a number:");
System.out.println(" 17026 % 10000 = 7026");
System.out.println("Determine if a number is odd:");
System.out.println(" 17026 % 2 = 0 || 4 % 2 = 0 || 5 % 2 = 1");
System.out.println("---------------------------------");
System.out.println("class Remainder {\n" +
"\n" +
" public static void main (String args[]) {\n" +
"\n" +
" int i = 10;\n" +
" int j = 3;\n" +
"\n" +
" System.out.println(\"i is \" + i);\n" +
" System.out.println(\"j is \" + j);\n" +
" \n" +
" int k = i % j;\n" +
" System.out.println(\"i%j is \" + k);\n" +
" }\n" +
"\n" +
"}");
}
public static void section1_3() {
System.out.println("Casting");
System.out.println("----------------------------------------");
System.out.println("public class MyClass {\n" +
" public static void main(String[] args) {\n" +
" int myInt = 9;\n" +
" double myDouble = myInt; // Automatic casting: int to double\n" +
"\n" +
" System.out.println(myInt); // Outputs 9\n" +
" System.out.println(myDouble); // Outputs 9.0\n" +
" }\n" +
"}");
System.out.println("public class MyClass {\n" +
" public static void main(String[] args) {\n" +
" double myDouble = 9.78;\n" +
" int myInt = (int) myDouble; // Manual casting: double to int\n" +
"\n" +
" System.out.println(myDouble); // Outputs 9.78\n" +
" System.out.println(myInt); // Outputs 9\n" +
" }\n" +
"}");
}
public static void section1_4() {
System.out.println("Parse Strings");
System.out.println("----------------------------------------");
System.out.println("String priceString = \"215.00\";");
System.out.println("priceDouble = Double.parseDouble(price)");
}
public static void section1_5() {
System.out.println("Scanners");
System.out.println("----------------------------------------");
System.out.println(" Use Type: [All Instances]");
System.out.println("Scanner input = new Scanner(System.in);");
System.out.println("----------------------------------------");
System.out.println(" Use Type: [String]");
System.out.println("System.out.println(\"Enter username: \");");
System.out.println("String userName = input.nextLine();");
System.out.println("System.out.println(\"Username is: \" + userName);");
System.out.println("----------------------------------------");
System.out.println(" Use Type: [int]");
System.out.println("System.out.println(\"Enter an int: \");");
System.out.println("int five =input.nextInt();");
System.out.println("System.out.println(\"five is [\"+five+\"]\");");
System.out.println("----------------------------------------");
System.out.println(" Use Type: [char]");
System.out.println("System.out.println(\"Enter a char: \");");
System.out.println("char letter = input.next().charAt(0);");
System.out.println("System.out.println(\"letter chosen is [\"+letter+\"]\");");
System.out.println("----------------------------------------");
System.out.println(" Use Type: [double]");
System.out.println("System.out.println(\"Enter double: \");");
System.out.println("double userDouble= input.nextDouble();");
System.out.println("System.out.println(\"double chosen is [\"+userDouble+\"]\");");
System.out.println("----------------------------------------");
System.out.println(" Use Type: [To Handle Input Exceptions]");
System.out.println("input.nextLine();");
System.out.println("----------------------------------------");
System.out.println(" Use Type: [All Instances]");
System.out.println("input.close();");
System.out.println("----------------------------------------");
System.out.println("[X] To Run an example!");
Scanner input = new Scanner(System.in);
char shouldRunExample = input.next().charAt(0);
if (shouldRunExample == 'X' || shouldRunExample == 'x') {
System.out.println(" public static void MinAndMaxInput (){\n" +
" Scanner input = new Scanner(System.in);\n" +
" int maxNum = Integer.MIN_VALUE;\n" +
" int minNum = Integer.MAX_VALUE;\n" +
" int newNum;\n" +
"\n" +
" while(true){\n" +
" System.out.println(\"Enter Number:\");\n" +
" boolean hasNextInt = input.hasNextInt();\n" +
"\n" +
" if(hasNextInt){\n" +
" newNum = input.nextInt();\n" +
" if(newNum>maxNum){maxNum=newNum;}\n" +
" if(newNum 59)) {\n" +
" return INVALID_VALUE_MESSAGE;\n" +
" }\n" +
" int hours = minutes / 60;\n" +
" int remainingMinutes = minutes % 60;\n" +
" String hoursString = hours + \"h\";\n" +
" if(hours < 10) {\n" +
" hoursString = \"0\" + hoursString;\n" +
" }\n" +
" String minutesString = remainingMinutes + \"m\";\n" +
" if(remainingMinutes < 10) {\n" +
" minutesString = \"0\" + minutesString;\n" +
" }\n" +
" String secondsString = seconds + \"s\";\n" +
" if(seconds < 10) {\n" +
" secondsString = \"0\" + secondsString;\n" +
" }\n" +
" return hoursString + \" \" + minutesString + \" \" + secondsString + \"\";\n" +
" }\n" +
"//Method - getDurationString - 1 Parameter\n" +
" private static String getDurationString(int seconds) {\n" +
" if(seconds < 0) {\n" +
" return INVALID_VALUE_MESSAGE;\n" +
" }\n" +
" int minutes = seconds / 60;\n" +
" int remainingSeconds = seconds % 60;\n" +
" return getDurationString(minutes, remainingSeconds);\n" +
" }\n" +
"}");
System.out.println("----------------CONSOLE-----------------");
System.out.println("00h 10m 30s\n" +
"01h 05m 05s\n" +
"01h 05m 05s\n" +
"Invalid value\n");
}
public static void section2_4() {
System.out.println("DigitSum & Palindrome Number Methods");
System.out.println("----------------------------------------");
System.out.println("***----------------------------------------");
System.out.println("***STILL NEEDS PALINDROME*****");
System.out.println("***----------------------------------------");
Scanner input14 = new Scanner(System.in);
System.out.println("Enter a number to SumDigits and check if it's a Palindrome ");
System.out.println("(Pick a 3 digit number for SumDigits annotations to match, however all integers work in this method)");
System.out.println("Number = ");
int number = input14.nextInt(); // 125
int ex1 = number % 10; // 125%10 -> 5
int div1 = number / 10; // 125/10 -> 12
int ex2 = div1 % 10; // 12%10 -> 2
int div2 = div1 / 10; // 12/10 -> 1
int ex3 = div2 % 10; // 1%10 -> 1
int div3 = div2 / 10; // 1/10 -> 0
int sumEx1 = ex1 + ex2; // 5+2 = 7
int sumEx2 = sumEx1 + ex3; //7+1 = 8
System.out.println(" public static int sumDigits (int number){\n" +
" //" + number + " < 10 = false\n" +
" if (number < 10) {\n" +
" return -1;\n" +
" }\n" +
" int sum = 0;\n" +
" // " + number + " > 0 = true\n" +
" // " + div1 + " > 0 = true\n" +
" // " + div2 + " > 0 = true\n" +
" // " + div3 + " > 0 = false\n" +
" while (number > 0) {\n" +
" //extract least significant digit\n" +
" int digit = number % 10;\n" +
" // " + number + "%10 = " + ex1 + "\n" +
" // " + div1 + "%10 = " + ex2 + "\n" +
" // " + div2 + "%10 = " + ex3 + "\n" +
" //Add the digit to the sum\n" +
" sum += digit;\n" +
" // sum+" + ex1 + " = " + ex1 + "\n" +
" // sum+" + ex2 + " = " + sumEx1 + "\n" +
" // sum+" + ex3 + " = " + sumEx2 + "\n" +
" //drop least significant digit\n" +
" number /= 10; //same as... number = number/10;\n" +
" //" + number + " / 10 = " + div1 + "\n" +
" //" + div1 + " / 10 = " + div2 + "\n" +
" //" + div2 + " / 10 = " + div3 + "\n" +
" }\n" +
" return sum;\n" +
" }");
System.out.println(sumDigits(number));
}
public static void section2_5() {
System.out.println("Drawing complex figures with static methods");
System.out.println("---------------------------------------------------------------");
System.out.println("Note: The structure of the output: egg, teacup, stop sign and hat figures");
System.out.println("System.out.println(\" ______\");\n" +
"System.out.println(\" / \\\\\");\n" +
"System.out.println(\"/ \\\\\");\n" +
"System.out.println(\"\\\\ /\");\n" +
"System.out.println(\" \\\\______/\");\n" +
"System.out.println();\n" +
"System.out.println(\"\\\\ /\");\n" +
"System.out.println(\" \\\\______/\");\n" +
"System.out.println(\"+--------+\");\n" +
"System.out.println();\n" +
"System.out.println(\" ______\");\n" +
"System.out.println(\" / \\\\\");\n" +
"System.out.println(\"/ \\\\\");\n" +
"System.out.println(\"| STOP |\");\n" +
"System.out.println(\"\\\\ /\");\n" +
"System.out.println(\" \\\\______/\");\n" +
"System.out.println();\n" +
"System.out.println(\" ______\");\n" +
"System.out.println(\" / \\\\\");\n" +
"System.out.println(\"/ \\\\\");\n" +
"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(" \\______/");
System.out.println("+--------+");
System.out.println();
System.out.println(" ______");
System.out.println(" / \\");
System.out.println("/ \\");
System.out.println("| STOP |");
System.out.println("\\ /");
System.out.println(" \\______/");
System.out.println();
System.out.println(" ______");
System.out.println(" / \\");
System.out.println("/ \\");
System.out.println("+--------+");
System.out.println();
}
//CHAPTER 3
public static void section3_1() {
System.out.println("Classes");
System.out.println("----------------------------------------");
System.out.println(" Code:");
System.out.println("public class Main {\n" +
" public static void main(String[] args) {\n" +
"\t Car toyota = new Car();\n" +
"\t Car acura = new Car();\n" +
"\t toyota.setModel(\"4Runner\");\n" +
"\t System.out.println(\"Toyota Model is \" + toyota.getModel());\n" +
" acura.setModel(\"Integra\");\n" +
" System.out.println(\"Acura Model is \" + acura.getModel());\n" +
" }\n" +
"}\n" +
"public class Car {\n" +
" private int doors;\n" +
" private int wheels;\n" +
" private String model;\n" +
" private String engine;\n" +
" private String colour;\n" +
"\n" +
" public void setModel(String model) {\n" +
" String validModel = model.toLowerCase();\n" +
" if(validModel.equals(\"4Runner\") || validModel.equals(\"Tacoma\")) {\n" +
" this.model = model;\n" +
" } \n" +
"\t\telse if(validModel.equals(\"Integra\") || validModel.equals(\"RSX\")){\n" +
"\t\t\tthis.model = model;\n" +
"\t\t}\n" +
"\t\telse {\n" +
" this.model = \"Unknown\";\n" +
" }\n" +
" }\n" +
"\n" +
" public String getModel() {\n" +
" return this.model;\n" +
" }\n" +
"}");
System.out.println("----------------------------------------");
System.out.println(" Console:");
System.out.println("Toyota Model is 4Runner");
System.out.println("Acura Model is Integra");
// public class Main {
// public static void main(String[] args) {
// Car toyota = new Car();
// Car acura = new Car();
// toyota.setModel("4Runner");
// System.out.println("Toyota Model is " + toyota.getModel());
// acura.setModel("Integra");
// System.out.println("Acura Model is " + acura.getModel());
// }
// }
// public class Car {
// private int doors;
// private int wheels;
// private String model;
// private String engine;
// private String colour;
//
// public void setModel(String model) {
// String validModel = model.toLowerCase();
// if(validModel.equals("4Runner") || validModel.equals("Tacoma")) {
// this.model = model;
// }
// else if(validModel.equals("Integra") || validModel.equals("RSX")){
// this.model = model;
// }
// else {
// this.model = "Unknown";
// }
// }
//
// public String getModel() {
// return this.model;
// }
// }
}
public static void section3_2() {
System.out.println("Class Vs Instance Vs Object Vs Reference");
System.out.println("----------------------------------------");
System.out.println("Analogy: Building a House...");
System.out.println("-----------------------------");
System.out.println("Class = The Blueprints");
System.out.println("Instance = Each House Built");
System.out.println("Object = The Actual Houses themselves");
System.out.println("Reference = The Address of the House");
System.out.println(" ");
System.out.println("Class House{");
System.out.println(" private String Color;");
System.out.println(" public String getColor(){");
System.out.println(" return color;");
System.out.println(" }");
System.out.println(" public void setColor(String color){");
System.out.println(" this.color = color;");
System.out.println(" }");
System.out.println("}");
System.out.println(" ");
System.out.println("public class Main{");
System.out.println(" public static void main (String [] args){");
System.out.println(" House blueHouse = new House(\"blue\");");
System.out.println(" House blueHouse = new House(\"blue\");");
System.out.println(" ");
System.out.println(" System.out.println(blueHouse.getColor()); //prints blue");
System.out.println(" System.out.println(anotherHouse.getColor()); //prints blue");
System.out.println(" ");
System.out.println(" anotherHouse.setColor(\"red\");");
System.out.println(" System.out.println(blueHouse.getColor()); //prints red");
System.out.println(" System.out.println(anotherHouse.getColor()); //prints red");
System.out.println(" ");
System.out.println(" House greenHouse = new House(\"green\");");
System.out.println(" anotherHouse = greenHouse;");
System.out.println(" ");
System.out.println(" System.out.println(blueHouse.getColor()); //prints red");
System.out.println(" System.out.println(greenHouse.getColor()); //prints green");
System.out.println(" System.out.println(anotherHouse.getColor()); //prints green");
System.out.println(" }");
System.out.println("}");
}
public static void section3_3() {
System.out.println("Getters & Setters");
System.out.println("----------------------------------------");
}
public static void section3_4() {
System.out.println("Constructors");
System.out.println("----------------------------------------");
}
public static void section3_5() {
System.out.println("This Vs Super");
System.out.println("----------------------------------------");
}
public static void section3_6() {
System.out.println("Method Overriding");
System.out.println("----------------------------------------");
}
public static void section3_7() {
System.out.println("Inheritance");
System.out.println("----------------------------------------");
}
//CHAPTER 4
public static void section4_1() {
//Print
System.out.println("1D Arrays");
System.out.println("----------------------------------------");
System.out.println(" Code: ");
System.out.println("public class Array1D {\n" +
" public static void main (String [] args){\n" +
" System.out.println(\"Welcome to KuroForest!!!\");\n" +
" String inventory[] = {\"Sword\", \"Shield\", \"Shadow-Clone jutsu\"};\n" +
" String orkUnit[] = {\"Close-Ranged Grunt\", \"Mid-ranged Grunt\", \"Long-range Grunt\"};\n" +
"\n" +
" System.out.println(\" Turn 1\");\n" +
" System.out.println(\"Your Character is using a \"+inventory[0]);\n" +
" System.out.println(\"Your facing a \"+orkUnit[0]+\", \"+orkUnit[1]+\" & \"+orkUnit[2]+\"!\");\n" +
" System.out.println(\" Turn 2\");\n" +
" System.out.println(\"Your Character is using a \"+inventory[1]);\n" +
" System.out.println(\"Your facing a \"+orkUnit[1]+\", \"+orkUnit[2]+\" & \"+orkUnit[0]+\"!\");\n" +
" System.out.println(\" Turn 3\");\n" +
" System.out.println(\"Your Character is using a \"+inventory[2]);\n" +
" System.out.println(\"Your facing a \"+orkUnit[2]+\", \"+orkUnit[0]+\" & \"+orkUnit[1]+\"!\"+\"\\n\");\n" +
"\n" +
" int numberOrksHATE[] = { 3, 5, 6, 7, 13 };\n" +
"\n" +
" System.out.println(\"Orks HATE the number ... \"+numberOrksHATE[0]+\" !\");\n" +
" }\n" +
"}");
System.out.println(" Console: ");
//Actual
System.out.println("Welcome to KuroForest!!!");
String inventory[] = {"Sword", "Shield", "Shadow-Clone jutsu"};
String orkUnit[] = {"Close-Ranged Grunt", "Mid-ranged Grunt", "Long-range Grunt"};
System.out.println(" Turn 1");
System.out.println("Your Character is using a " + inventory[0]);
System.out.println("Your facing a " + orkUnit[0] + ", " + orkUnit[1] + " & " + orkUnit[2] + "!");
System.out.println(" Turn 2");
System.out.println("Your Character is using a " + inventory[1]);
System.out.println("Your facing a " + orkUnit[1] + ", " + orkUnit[2] + " & " + orkUnit[0] + "!");
System.out.println(" Turn 3");
System.out.println("Your Character is using a " + inventory[2]);
System.out.println("Your facing a " + orkUnit[2] + ", " + orkUnit[0] + " & " + orkUnit[1] + "!" + "\n");
int numberOrksHATE[] = {3, 5, 6, 7, 13};
System.out.println("Orks HATE the number ... " + numberOrksHATE[0] + " !");
//Alternative Method
// System.out.println("1D Arrays");
// System.out.println("----------------------------------------");
// System.out.println("Rules: ");
// System.out.println(" ");
// System.out.println("import java.util.Scanner;\n" +
// "public class array {\n" +
// " //Collect Input\n" +
// " private static Scanner scanner = new Scanner(System.in);\n" +
// "\n" +
// " //Get Input, Create Array & Get Average\n" +
// " public static void main(String[] args) {\n" +
// " int[] myIntegers = getIntegers(5);\n" +
// " for(int i=0; i 0 = true
// 12 > 0 = true
// 1 > 0 = true
// 0 > 0 = false
while (number > 0) {
//extract least significant digit
// 125%10 = 5
// 12%10 = 2
// 1%10 = 1
int digit = number % 10;
sum += digit;
// sum+5 = 5
// sum+2 = 7
// sum+1 = 8
//drop least significant digit
//125 / 10 = 12
//12 / 10 = 1
//1 / 10 = 0
number /= 10; //same as... number = number/10;
}
return sum;
}
// int year = 2018;
// int month = -1;
// System.out.println(isLeapYear(year));
// System.out.println(getDaysInMonth(month,year));
public static boolean isLeapYear (int year){
if (year >= 1 && year<= 9999){
int testA = year%4;
int testB = year%100;
int testC = year%400;
if ((testA==0 && testB!=0)|| testC==0 ){
return true;
}
else {
return false;
}
}
else{
return false;
}
}
public static int getDaysInMonth (int month, int year) {
if (month < 1 || month > 12) {
return -1;
} else if (year < 1 || year > 9999) {
return -1;
} else {
switch (month) {
//April, June, September & November
case 4:
case 6:
case 9:
case 11:
return 30;
//February
case 2:
if (isLeapYear(year)) {
return 29;
} else {
return 28;
}
//January, March, May, July, August, October, December
default:
return 31;
}
}
}
private static void MinAndMaxInput (){
Scanner input = new Scanner(System.in);
int maxNum = Integer.MIN_VALUE;
int minNum = Integer.MAX_VALUE;
int newNum;
while(true){
System.out.println("Enter Number:");
boolean hasNextInt = input.hasNextInt();
if(hasNextInt){
newNum = input.nextInt();
if(newNum>maxNum){maxNum=newNum;}
if(newNum