├── Assignments ├── Getting Started with Java │ ├── Java_Basics_Assignment.pdf │ ├── Main.java │ └── StudentID.java ├── Leveraging Basic Concepts │ ├── Leveraging_Basic_Concepts_Assignment.pdf │ ├── Main.java │ └── TaxCalculator.java └── Object Oriented Programming │ ├── Bakery.java │ ├── Main.java │ └── Object_Oriented_Programming_Assignment.pdf ├── Connect4Game ├── Connect4.jar ├── Output + C4 + 1.png ├── Output + C4 + 2.png ├── Output + C4 + 3.png ├── Output + C4 + 4.png ├── ReadME.MD ├── bin │ ├── Controller$Disc.class │ ├── Controller.class │ ├── Main.class │ └── game.fxml └── source │ └── connectfour │ ├── Controller.java │ ├── Main.java │ └── game.fxml ├── Core_Java_Certificate 06-06-2020.jpg ├── README.md └── Temperature Converter Tool ├── C2F + 1.png ├── C2F + 2.png ├── C2F + 3.png ├── C2F + 4.png ├── ReadME.MD ├── Temperature Converter Tool.jar ├── bin ├── Controller.class ├── MyMain.class └── app_layout.fxml └── com └── internshala └── javafxapp ├── Controller.java ├── MyMain.java └── app_layout.fxml /Assignments/Getting Started with Java/Java_Basics_Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Assignments/Getting Started with Java/Java_Basics_Assignment.pdf -------------------------------------------------------------------------------- /Assignments/Getting Started with Java/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | 6 | /* Student ID Card Generator */ 7 | Scanner scanner = new Scanner(System.in); 8 | 9 | System.out.println("Enter Name: "); 10 | String name = scanner.nextLine(); 11 | 12 | System.out.println("Enter Age: "); 13 | int age = scanner.nextInt(); 14 | 15 | System.out.println("Enter Blood group: "); 16 | String bloodGroup = scanner.nextLine(); 17 | 18 | scanner.close(); 19 | 20 | String groupName; 21 | 22 | if (age >= 20) { 23 | groupName = "RED"; 24 | } else if (age >= 15) { 25 | groupName = "BLUE"; 26 | } else if (age >= 10) { 27 | groupName = "YELLOW"; 28 | } else { 29 | groupName = "NO GROUP"; 30 | } 31 | 32 | System.out.println("----------------------------"); 33 | System.out.println(" Name: " + name); 34 | System.out.println(" Age: " + age); 35 | System.out.println(" Blood Group: " + bloodGroup); 36 | System.out.println("----------------------------"); 37 | System.out.println(" Your group is " + groupName); 38 | System.out.println("----------------------------"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assignments/Getting Started with Java/StudentID.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class StudentID 4 | { 5 | /* Student ID Card Generator */ 6 | public static void main(String[] args) 7 | { 8 | String studentName; 9 | int studentAge; 10 | String bloodGroup; 11 | String studentGroup = ""; 12 | 13 | /* Scanning input data from the user */ 14 | Scanner reader = new Scanner(System.in); 15 | System.out.println("Enter your name :"); 16 | studentName = reader.nextLine(); 17 | System.out.println("Enter your age :"); 18 | studentAge = reader.nextInt(); 19 | System.out.println("Enter your blood group :"); 20 | bloodGroup = reader.next(); 21 | 22 | /* Deciding the `studentGroup` based on the age */ 23 | if (studentAge >= 20) 24 | { 25 | studentGroup = "RED"; 26 | } 27 | else if (studentAge >= 15 && studentAge < 20) 28 | { 29 | studentGroup = "BLUE"; 30 | } 31 | else if (studentAge >= 10 && studentAge < 15) 32 | { 33 | studentGroup = "YELLOW"; 34 | } 35 | 36 | /* Printing the ID-Card */ 37 | System.out.println("----------------------------------"); 38 | System.out.println("Name: " +studentName); 39 | System.out.println("Age: " +studentAge); 40 | System.out.println("Blood Group: " +bloodGroup); 41 | System.out.println("----------------------------------"); 42 | System.out.println("Your group is " +studentGroup); 43 | System.out.println("----------------------------------"); 44 | 45 | reader.close(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Assignments/Leveraging Basic Concepts/Leveraging_Basic_Concepts_Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Assignments/Leveraging Basic Concepts/Leveraging_Basic_Concepts_Assignment.pdf -------------------------------------------------------------------------------- /Assignments/Leveraging Basic Concepts/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | 6 | /* Tax Calculator */ 7 | System.out.println(" Tax Calculator App "); 8 | System.out.println("----- WELCOME ------"); 9 | 10 | System.out.println(); // Just a new line 11 | 12 | Scanner scanner = new Scanner(System.in); 13 | System.out.println("Enter total person count: "); 14 | int n = scanner.nextInt(); 15 | 16 | System.out.println(); // New line 17 | 18 | String[] names = new String[n]; 19 | long[] incomes = new long[n]; 20 | 21 | for (int i = 0; i < n; i++) { 22 | System.out.println("Enter name " + (i+1) + " : "); 23 | names[i] = scanner.next(); 24 | System.out.println("Enter " + names[i] + "'s Annual Income: "); 25 | incomes[i] = scanner.nextLong(); 26 | System.out.println(); // new line 27 | } 28 | 29 | scanner.close(); 30 | 31 | System.out.println(" Names with liable taxes"); 32 | System.out.println("---------------------------"); 33 | 34 | for (int i = 0; i < n; i++) { 35 | calculateTax(names[i], incomes[i]); 36 | } 37 | } 38 | 39 | private static void calculateTax(String name, long income) { 40 | 41 | long tax; 42 | 43 | if (income >= 300000) { 44 | tax = income * 20 / 100; 45 | } else if (income >= 100000) { 46 | tax = income * 10 / 100; 47 | } else { 48 | tax = 0; 49 | } 50 | 51 | System.out.println(" " + name +" : "+ '\u20B9' + " " + tax); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Assignments/Leveraging Basic Concepts/TaxCalculator.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; // Importing Scanner class 2 | 3 | public class TaxCalculator 4 | { 5 | // Method for TAX Calculation 6 | public static void calculateTax(String name, long income) 7 | { 8 | long taxAmount; 9 | long taxPercentage = 0L; // `L` for long type declarartion 10 | 11 | // Deciding `taxpercentage` based on income 12 | if (income >= 300000) 13 | { 14 | taxPercentage = 20L; 15 | } 16 | else if (income >= 100000 && income < 300000) 17 | { 18 | taxPercentage = 10L; 19 | } 20 | else if (income < 100000) 21 | { 22 | taxPercentage = 0L; 23 | } 24 | // Calculating `taxAmount` 25 | taxAmount = (taxPercentage)*(income)/(100); 26 | 27 | System.out.println(name+ " : ₹ " +taxAmount); 28 | } 29 | 30 | public static void main(String[] args) 31 | { 32 | int personCount; 33 | 34 | System.out.println("Tax Calculator App"); 35 | System.out.println("----- WELCOME -----"); 36 | 37 | Scanner reader = new Scanner(System.in); 38 | System.out.println("Enter total person count: "); 39 | personCount = reader.nextInt(); 40 | 41 | String[] namesArray = new String[personCount]; // Array of string to store 'names' 42 | long[] incomesArray = new long[personCount]; // Array of long to store 'incomes' 43 | 44 | // Reading user's input 45 | for (int i=0; i < personCount; i++) 46 | { 47 | System.out.println("Enter Name " +(i+1)+ " : "); 48 | namesArray[i] = reader.next(); 49 | System.out.println("Enter " +namesArray[i]+ "'s Annual Income : "); 50 | incomesArray[i] = reader.nextLong(); 51 | } 52 | for (int i=0; i < personCount; i++) 53 | { 54 | calculateTax(namesArray[i], incomesArray[i]); // Calling method with required parameters 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assignments/Object Oriented Programming/Bakery.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | class Cake // Parent Class 4 | { 5 | String name; 6 | float price; 7 | // GETTER 8 | public String getName() 9 | { return name; } 10 | public float getPrice() 11 | { return price; } 12 | 13 | // SETTER 14 | public void setName(String newName) 15 | { this.name = newName; } 16 | public void setPrice(float newPrice) 17 | { this.price = newPrice; } 18 | void display() 19 | { 20 | System.out.println(name +" : " +'\u20B9'+ " " +price+ " per pound"); 21 | } 22 | } 23 | 24 | class Pastry extends Cake // Child Class 25 | { 26 | @Override 27 | void display() 28 | { 29 | System.out.println(name +" : " +'\u20B9'+ " " +price+ " per piece"); 30 | } 31 | } 32 | 33 | public class Bakery // Bakery Class 34 | { 35 | public static void main(String[] args) 36 | { 37 | /* `Cake` & `Pastry` Object creation */ 38 | Cake cake1 = new Cake(); 39 | Cake cake2 = new Cake(); 40 | Pastry pastry1 = new Pastry(); 41 | Pastry pastry2 = new Pastry(); 42 | 43 | // Getter & Setter 44 | cake1.setName("Chocolate Brownie"); 45 | cake1.setPrice(250f); 46 | cake2.setName("Chocolate Maple"); 47 | cake2.setPrice(300f); 48 | pastry1.setName("Black Forest"); 49 | pastry1.setPrice(35f); 50 | pastry2.setName("Choco Truffle"); 51 | pastry2.setPrice(40f); 52 | 53 | /* ArrayList for `Cakes` & `Pastries` */ 54 | List cakesList = new ArrayList(); 55 | cakesList.add(cake1); 56 | cakesList.add(cake2); 57 | List pastriesList = new ArrayList(); 58 | pastriesList.add(pastry1); 59 | pastriesList.add(pastry2); 60 | 61 | System.out.println(" Today's Special Menu "); 62 | System.out.println("------------------------------------"); 63 | System.out.println(); 64 | System.out.println("Special Cakes "); 65 | System.out.println("------------------------------------"); 66 | /*cake1.display(); 67 | cake2.display();*/ 68 | for (Cake object : cakesList) 69 | { 70 | object.display(); 71 | } 72 | 73 | System.out.println(); 74 | System.out.println("Special Pastries "); 75 | System.out.println("------------------------------------"); 76 | /*pastry1.display(); 77 | pastry2.display();*/ 78 | 79 | for (Pastry object : pastriesList) 80 | { 81 | object.display(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Assignments/Object Oriented Programming/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.List; 3 | 4 | public class Main { 5 | public static void main(String[] args) { 6 | 7 | // List of Today's Special Cake 8 | Cake brownieCake = new Cake(); 9 | brownieCake.setName("Chocolate Brownie"); 10 | brownieCake.setPrice(250); 11 | 12 | Cake mapleCake = new Cake(); 13 | mapleCake.setName("Chocolate Maple"); 14 | mapleCake.setPrice(300); 15 | 16 | List cakeList = new ArrayList<>(); 17 | cakeList.add(brownieCake); 18 | cakeList.add(mapleCake); 19 | 20 | // List of Today's Special Pastries 21 | Pastry blackForestPastry = new Pastry(); 22 | blackForestPastry.setName("Black Forest"); 23 | blackForestPastry.setPrice(35); 24 | 25 | Pastry chocoTrufflePastry = new Pastry(); 26 | chocoTrufflePastry.setName("Choco Truffle"); 27 | chocoTrufflePastry.setPrice(40); 28 | 29 | List pastryList = new ArrayList<>(); 30 | pastryList.add(blackForestPastry); 31 | pastryList.add(chocoTrufflePastry); 32 | 33 | System.out.println(" Today's Special Menu"); 34 | System.out.println("-----------------------------------------"); 35 | 36 | System.out.println(); 37 | System.out.println(" Special Cakes"); 38 | System.out.println(" -------------------------------"); 39 | 40 | for (Cake cake: cakeList) { 41 | cake.display(); 42 | } 43 | 44 | System.out.println(); 45 | System.out.println(" Special Pastries"); 46 | System.out.println(" -------------------------------"); 47 | 48 | for (Pastry pastry: pastryList) { 49 | pastry.display(); 50 | } 51 | } 52 | } 53 | 54 | /*** Cake Class ***/ 55 | class Cake { 56 | 57 | String name; 58 | float price; 59 | 60 | public String getName() { 61 | return name; 62 | } 63 | 64 | public void setName(String name) { 65 | this.name = name; 66 | } 67 | 68 | public float getPrice() { 69 | return price; 70 | } 71 | 72 | public void setPrice(float price) { 73 | this.price = price; 74 | } 75 | 76 | public void display() { 77 | System.out.println(" " + name + " : " + '\u20B9' + " " + price + " per pound"); 78 | } 79 | } 80 | 81 | /*** Pastry Class ***/ 82 | public class Pastry extends Cake { 83 | 84 | @Override 85 | public void display() { 86 | System.out.println(" " + name + " : " + '\u20B9' + " " + price + " per piece"); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Assignments/Object Oriented Programming/Object_Oriented_Programming_Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Assignments/Object Oriented Programming/Object_Oriented_Programming_Assignment.pdf -------------------------------------------------------------------------------- /Connect4Game/Connect4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/Connect4.jar -------------------------------------------------------------------------------- /Connect4Game/Output + C4 + 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/Output + C4 + 1.png -------------------------------------------------------------------------------- /Connect4Game/Output + C4 + 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/Output + C4 + 2.png -------------------------------------------------------------------------------- /Connect4Game/Output + C4 + 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/Output + C4 + 3.png -------------------------------------------------------------------------------- /Connect4Game/Output + C4 + 4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/Output + C4 + 4.png -------------------------------------------------------------------------------- /Connect4Game/ReadME.MD: -------------------------------------------------------------------------------- 1 | # JAVA-FX CONNECT-4-GAME 2 | 3 | ![Java FX](https://img.shields.io/badge/-Finished-brightgreen.svg) 4 | ### I've created the Connect4Game using Java in IntelliJ IDEA. You can access the .JAR file in the repo! 5 | ### To run the APP, you must have Java [JDK v8] installed in your system. For a general overview, you can checkout the output screenshots included in the repo!! Thanks :santa: 6 | ```bash 7 | The Connect 4 Game Rules are easy to understand. In fact, it is in the name. 8 | To win *Connect Four*, all you have to do is to choose a color and then take turns 9 | dropping colored discs from the top into a *seven-column, six-row* vertically suspended grid. 10 | The pieces fall straight down, occupying the next available space within the column. 11 | The objective of this game is to *connect four* of your colored checker pieces in a row, 12 | much the same as tic tac toe. This can be done horizontally, vertically or diagonally. 13 | Each player will drop in one checker piece at a time. This will give you a chance to either build 14 | your row, or stop your opponent from getting four in a row. 15 | 16 | The game is over either when you or your friend reaches four in a row, 17 | or when all forty two slots are filled, ending in a stalemate. 18 | If you and your friend decide to play again, the first player typically goes first. 19 | The rules of the game are easy to learn, but difficult to master. That is the beauty of Connect Four. 20 | Now that you know the *Connect 4* board game rules, now is the time to challenge everyone you know. 21 | No matter their age or skill level, they can play this game with you. 22 | Now that you understand the rules, share *Connect Four* with everyone around you. 23 | You’ll be glad you did. 24 | ``` 25 | 26 | * **Main.java** `JAVA` 27 | * **Controller** `JAVA-fx` 28 | * **game** `FXML` 29 | 30 |

31 | 32 |

33 |

34 | 35 |

36 |

37 | 38 |

39 |

40 | 41 |

42 | 43 | > :hash:#JAVA #Lockdown :hash:#FX #Jar-File :hash:#App #FXML :hash:#Dev 44 | 45 | #### :100: Get Socialistic :100: 46 | ➧ [Facebook](https://www.facebook.com/guru.shreyansh) 47 | ➧ [Instagram](https://www.instagram.com/guru_shreyansh/) 48 | ➧ [Twitter](https://twitter.com/GURU_Shreyansh) 49 | 50 | @guru-shreyansh 51 | -------------------------------------------------------------------------------- /Connect4Game/bin/Controller$Disc.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/bin/Controller$Disc.class -------------------------------------------------------------------------------- /Connect4Game/bin/Controller.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/bin/Controller.class -------------------------------------------------------------------------------- /Connect4Game/bin/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Connect4Game/bin/Main.class -------------------------------------------------------------------------------- /Connect4Game/bin/game.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 44 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Connect4Game/source/connectfour/Controller.java: -------------------------------------------------------------------------------- 1 | package connectfour; 2 | 3 | import javafx.animation.TranslateTransition; 4 | import javafx.application.Platform; 5 | import javafx.fxml.FXML; 6 | import javafx.fxml.Initializable; 7 | import javafx.geometry.Point2D; 8 | import javafx.scene.control.*; 9 | import javafx.scene.layout.GridPane; 10 | import javafx.scene.layout.Pane; 11 | import javafx.scene.paint.Color; 12 | import javafx.scene.shape.Circle; 13 | import javafx.scene.shape.Rectangle; 14 | import javafx.scene.shape.Shape; 15 | import javafx.util.Duration; 16 | 17 | import java.net.URL; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.Optional; 21 | import java.util.ResourceBundle; 22 | import java.util.stream.Collectors; 23 | import java.util.stream.IntStream; 24 | 25 | 26 | public class Controller implements Initializable 27 | { 28 | private static final int COLUMNS = 7; 29 | private static final int ROWS = 6; 30 | private static final int CIRCLE_DIAMETER = 80; 31 | 32 | private static final String discColor1 = "#24303E"; 33 | private static final String discColor2 = "#4CAA88"; 34 | 35 | private static String PLAYER_ONE = "Player One"; // Changes on User input 36 | private static String PLAYER_TWO = "Player Two"; // Changes on User input 37 | 38 | private boolean isPlayerOneTurn = true; 39 | 40 | private Disc[][] insertedDiscsArray = new Disc[ROWS][COLUMNS]; 41 | // Array for Structural changes 42 | 43 | @FXML 44 | public GridPane rootGridPane; 45 | 46 | @FXML 47 | public Pane insertedDiscsPane; 48 | 49 | @FXML 50 | public Label playerNameLabel; 51 | 52 | @FXML 53 | public TextField playerOneTextField, playerTwoTextField; 54 | 55 | @FXML 56 | public Button setNamesButton; 57 | 58 | private boolean isAllowedToInsert = true; 59 | // Flag to prevent user from dropping multiple Discs at once 60 | 61 | 62 | public void createPlayground() 63 | { 64 | setNamesButton.setOnAction(event -> 65 | { 66 | PLAYER_ONE = playerOneTextField.getText(); 67 | PLAYER_TWO = playerTwoTextField.getText(); 68 | }); 69 | 70 | Shape rectangleWithHoles = createGameStructuralGrid(); 71 | rootGridPane.add(rectangleWithHoles, 0, 1); 72 | // Adding rectangleWithHoles to rootGridPane at (0,1) 73 | List rectangleList = createClickableColumns(); 74 | 75 | for (Rectangle rectangle: rectangleList) 76 | { 77 | rootGridPane.add(rectangle, 0, 1); 78 | // Adding rectangles to rectangleLists 79 | } 80 | } 81 | 82 | private Shape createGameStructuralGrid() 83 | { 84 | Shape rectangleWithHoles = new Rectangle 85 | ((COLUMNS+1)*CIRCLE_DIAMETER, (ROWS+1)*CIRCLE_DIAMETER); 86 | 87 | for (int row=0; row < ROWS; row++) // 2D Array of Circles 88 | { 89 | for (int col=0; col < COLUMNS; col++) 90 | { 91 | Circle circle = new Circle(); 92 | circle.setRadius(CIRCLE_DIAMETER/2); 93 | circle.setCenterX(CIRCLE_DIAMETER/2); 94 | circle.setCenterY(CIRCLE_DIAMETER/2); 95 | circle.setSmooth(true); 96 | 97 | 98 | circle.setTranslateX(col * (CIRCLE_DIAMETER + 5) + CIRCLE_DIAMETER/4); 99 | circle.setTranslateY(row * (CIRCLE_DIAMETER + 5) + CIRCLE_DIAMETER/4); 100 | 101 | rectangleWithHoles = Shape.subtract(rectangleWithHoles, circle); 102 | } 103 | } 104 | rectangleWithHoles.setFill(Color.WHITE); 105 | 106 | return rectangleWithHoles; 107 | } 108 | 109 | private List createClickableColumns() 110 | { 111 | List rectangleList = new ArrayList<>(); 112 | 113 | for (int col=0; col < COLUMNS; col++) 114 | { 115 | Rectangle rectangle = new Rectangle 116 | (CIRCLE_DIAMETER, (ROWS + 1) * CIRCLE_DIAMETER); 117 | rectangle.setFill(Color.TRANSPARENT); 118 | rectangle.setTranslateX(col * (CIRCLE_DIAMETER + 5) + CIRCLE_DIAMETER/4); 119 | 120 | rectangle.setOnMouseEntered(event -> rectangle.setFill(Color.valueOf("#eeeeee26"))); 121 | // Hover Effect 122 | rectangle.setOnMouseExited(event -> rectangle.setFill(Color.TRANSPARENT)); 123 | 124 | final int column = col; 125 | rectangle.setOnMouseClicked(event -> 126 | { 127 | if (isAllowedToInsert) 128 | { 129 | isAllowedToInsert = false; 130 | // Prevents user from dropping multiple Discs at once 131 | insertDisc(new Disc(isPlayerOneTurn), column); 132 | } 133 | }); 134 | rectangleList.add(rectangle); 135 | } 136 | return rectangleList; 137 | } 138 | 139 | private void insertDisc(Disc disc, int column) 140 | { 141 | int row = ROWS-1; 142 | while (row >= 0) 143 | { 144 | if (getDiscIfPresent(row, column) == null) 145 | break; // To place Disc on the Top of the column 146 | 147 | row--; 148 | } 149 | 150 | if (row < 0) // If the row is Full, no more Disc can be inserted 151 | return; 152 | 153 | insertedDiscsArray[row][column] = disc; // For Structural Changes : For Developers 154 | insertedDiscsPane.getChildren().add(disc); // For Visual Changes : For Users 155 | 156 | disc.setTranslateX(column * (CIRCLE_DIAMETER + 5) + CIRCLE_DIAMETER / 4.0); 157 | 158 | int currentRow = row; 159 | TranslateTransition translateTransition 160 | = new TranslateTransition(Duration.seconds(0.5), disc); 161 | translateTransition.setToY(row * (CIRCLE_DIAMETER + 5) + 60); // **** 162 | translateTransition.setOnFinished(event -> 163 | { 164 | isAllowedToInsert = true; // Allows next Disc to be dropped 165 | if (gameEnded(currentRow, column)) 166 | { 167 | gameOver(); 168 | return; // Ends the Game 169 | } 170 | 171 | isPlayerOneTurn = !isPlayerOneTurn; // Toggling b/w the Players 172 | 173 | playerNameLabel.setText(isPlayerOneTurn? PLAYER_ONE : PLAYER_TWO); 174 | // Changing Players 175 | }); 176 | translateTransition.play(); // To play the Animation 177 | } 178 | 179 | private boolean gameEnded(int row, int column) 180 | { 181 | List verticalPoints = IntStream.rangeClosed(row-3, row+3) // 0,1,2,3,4,5 182 | .mapToObj(r -> new Point2D(r, column)).collect(Collectors.toList()); 183 | // Point2D --> 0,3 1,3 2,3 3,3 4,3 5,3 184 | 185 | List horizontalPoints = IntStream.rangeClosed(column-3, column+3) 186 | .mapToObj(c -> new Point2D(row, c)).collect(Collectors.toList()); 187 | 188 | Point2D startPoint1 = new Point2D(row-3, column+3); 189 | List diagonal1Points = IntStream.rangeClosed(0, 6) 190 | .mapToObj(i -> startPoint1.add(i, -i)).collect(Collectors.toList()); 191 | 192 | Point2D startPoint2 = new Point2D(row-3, column-3); 193 | List diagonal2Points = IntStream.rangeClosed(0, 6) 194 | .mapToObj(i -> startPoint2.add(i, i)).collect(Collectors.toList()); 195 | 196 | boolean isEnded = checkCombinations(verticalPoints) || checkCombinations(horizontalPoints) 197 | || checkCombinations(diagonal1Points) || checkCombinations(diagonal2Points); 198 | // Checking for Matches !! 199 | 200 | return isEnded; 201 | } 202 | 203 | private boolean checkCombinations(List points) 204 | { 205 | int chain = 0; 206 | for (Point2D point : points) 207 | { 208 | int rowIndexForArray = (int) point.getX(); 209 | int columnIndexForArray = (int) point.getY(); 210 | 211 | Disc disc = getDiscIfPresent(rowIndexForArray, columnIndexForArray); 212 | 213 | if (disc != null && disc.isPlayerOneMove == isPlayerOneTurn) 214 | { 215 | chain++; 216 | if (chain == 4) 217 | { 218 | return true; 219 | } 220 | } 221 | else 222 | { 223 | chain = 0; 224 | } 225 | } 226 | return false; 227 | } 228 | 229 | private Disc getDiscIfPresent(int row, int column) 230 | // To Prevent ArrayIndexOutOfBoundException 231 | { 232 | if (row >= ROWS || row < 0 || column >= COLUMNS || column < 0) 233 | return null; 234 | 235 | return insertedDiscsArray[row][column]; 236 | } 237 | 238 | private void gameOver() 239 | { 240 | String winner = isPlayerOneTurn? PLAYER_ONE : PLAYER_TWO; 241 | System.out.println("Winner is : " +winner); 242 | Alert alert = new Alert(Alert.AlertType.INFORMATION); 243 | alert.setTitle("Connect 4"); 244 | alert.setHeaderText("The Winner is : " +winner+ " !!"); 245 | alert.setContentText("Want to play again ?"); 246 | 247 | ButtonType yesBtn = new ButtonType("Yes"); 248 | ButtonType noBtn = new ButtonType("No, Exit"); 249 | alert.getButtonTypes().setAll(yesBtn, noBtn); 250 | 251 | Platform.runLater( () -> 252 | { 253 | Optional btnClicked = alert.showAndWait(); 254 | if (btnClicked.isPresent() && btnClicked.get() == yesBtn) 255 | { 256 | // Yes will Reset the Game 257 | resetGame(); 258 | } 259 | else 260 | { 261 | // No will Close the Game 262 | Platform.exit(); // Closes the Virtual Machine 263 | System.exit(0); // Closes the Application 264 | } 265 | }); 266 | } 267 | 268 | public void resetGame() // Accesible in Main as well 269 | { 270 | // Visually 271 | insertedDiscsPane.getChildren().clear(); // Remove all Inserted Disc from Pane 272 | 273 | // Structurally 274 | for (int row=0; row < insertedDiscsArray.length; row++) 275 | { 276 | for (int col=0; col < insertedDiscsArray[row].length; col++) 277 | { 278 | insertedDiscsArray[row][col] = null; 279 | // Make all elements of insertedDiscsArray = NULL 280 | } 281 | } 282 | isPlayerOneTurn = true; 283 | playerNameLabel.setText(PLAYER_ONE); 284 | 285 | createPlayground(); // Prepare a fresh Playground 286 | } 287 | 288 | private static class Disc extends Circle 289 | { 290 | private final boolean isPlayerOneMove; 291 | 292 | public Disc(boolean isPlayerOneMove) 293 | { 294 | this.isPlayerOneMove = isPlayerOneMove; 295 | setRadius(CIRCLE_DIAMETER/2); 296 | setCenterX(CIRCLE_DIAMETER/2); 297 | setCenterX(CIRCLE_DIAMETER/2); 298 | setFill(isPlayerOneMove? Color.valueOf(discColor1) : Color.valueOf(discColor2)); 299 | } 300 | } 301 | 302 | @Override 303 | public void initialize(URL location, ResourceBundle resources) 304 | { } 305 | } 306 | -------------------------------------------------------------------------------- /Connect4Game/source/connectfour/Main.java: -------------------------------------------------------------------------------- 1 | package connectfour; 2 | 3 | import javafx.application.Application; 4 | import javafx.application.Platform; 5 | import javafx.fxml.FXMLLoader; 6 | import javafx.scene.Scene; 7 | import javafx.scene.control.*; 8 | import javafx.scene.layout.GridPane; 9 | import javafx.scene.layout.Pane; 10 | import javafx.stage.Stage; 11 | 12 | public class Main extends Application 13 | { 14 | private Controller controller; 15 | 16 | @Override 17 | // Mandatory to override Start method 18 | // Init & Stop are optional to override 19 | 20 | public void start(Stage primaryStage) throws Exception // Stage is outermost container of the app 21 | { 22 | System.out.println("Application Started"); 23 | 24 | // Loader connects MyMain with FXML file 25 | FXMLLoader loader = new FXMLLoader(getClass().getResource("game.fxml")); 26 | GridPane rootGridPane = loader.load(); // Loads rootNode as GridPane 27 | 28 | controller = loader.getController(); 29 | controller.createPlayground(); 30 | 31 | MenuBar menuBar = createMenu(); 32 | 33 | menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); 34 | // Matches the menuBar width with primaryStage width 35 | 36 | Pane menuPane = (Pane) rootGridPane.getChildren().get(0); 37 | menuPane.getChildren().add(menuBar); 38 | 39 | Scene scene = new Scene(rootGridPane); 40 | 41 | // Setting the scene 42 | primaryStage.setScene(scene); 43 | primaryStage.setTitle("Connect 4"); 44 | primaryStage.setResizable(false); // If you want to prevent the user from resizing the Stage 45 | primaryStage.show(); 46 | } 47 | 48 | private MenuBar createMenu() 49 | { 50 | //File Menu 51 | Menu fileMenu = new Menu("File"); 52 | 53 | MenuItem newGame = new MenuItem("New Game"); 54 | newGame.setOnAction(event -> controller.resetGame()); // Replaced with Lambda 55 | 56 | MenuItem resetGame = new MenuItem("Reset Game"); 57 | resetGame.setOnAction(event -> controller.resetGame()); // Replaced with Lambda 58 | 59 | SeparatorMenuItem separatorMenuItem = new SeparatorMenuItem(); 60 | // allows for a horizontal Separator to be embedded within it 61 | 62 | MenuItem exitGame = new MenuItem("Exit Game"); 63 | exitGame.setOnAction(event -> exitGame()); 64 | 65 | fileMenu.getItems().addAll(newGame, resetGame, separatorMenuItem, exitGame); 66 | 67 | //Help Menu 68 | Menu helpMenu = new Menu("Help"); 69 | 70 | MenuItem aboutGame = new MenuItem("About Connect 4"); 71 | aboutGame.setOnAction(event -> aboutConnect4()); 72 | SeparatorMenuItem separatorItem = new SeparatorMenuItem(); 73 | MenuItem aboutMe = new MenuItem("About Me"); 74 | aboutMe.setOnAction(event -> aboutMe()); 75 | 76 | helpMenu.getItems().addAll(aboutGame, separatorItem, aboutMe); 77 | 78 | // Menu Bar 79 | MenuBar menuBar = new MenuBar(); 80 | menuBar.getMenus().addAll(fileMenu, helpMenu); // Adding Menus to Menu Bar 81 | 82 | return menuBar; 83 | } 84 | 85 | private void aboutMe() 86 | { 87 | Alert alert = new Alert(Alert.AlertType.INFORMATION); 88 | alert.setTitle("About The Developer"); 89 | alert.setHeaderText("Shreyansh Kumar Singh"); 90 | alert.setContentText("Hi! I am Shreyansh, a developer focused on crafting" + 91 | " great web/app experiences. Designing and Coding have been my passion since" + 92 | " the days I started working with computers but I found myself into app" + 93 | " design/development since 2019. I enjoy creating beautifully designed," + 94 | " intuitive and functional applications & websites. Being an Engineer" + 95 | " I believe in using science to find creative practical solutions." + 96 | " My other hobbies includes Photography, Cooking & Painting."); 97 | 98 | alert.show(); // To display the About section 99 | } 100 | 101 | private void aboutConnect4() 102 | { 103 | Alert alert = new Alert(Alert.AlertType.INFORMATION); 104 | alert.setTitle("About Connect 4 Game"); 105 | alert.setHeaderText("How To Play ?"); 106 | alert.setContentText("The Connect 4 Game Rules are easy to understand." + 107 | " In fact, it is in the name. To win Connect Four, all you have to do" + 108 | " is to choose a color and then take turns dropping colored discs from" + 109 | " the top into a seven-column, six-row vertically suspended grid." + 110 | " The pieces fall straight down, occupying the next available space within the column." + 111 | " The objective of this game is to connect four of your colored checker pieces in a row," + 112 | " much the same as tic tac toe. This can be done horizontally, vertically or diagonally." + 113 | " Each player will drop in one checker piece at a time. This will give you a chance" + 114 | " to either build your row, or stop your opponent from getting four in a row." + 115 | "\n\n" + 116 | "\tThe game is over either when you or your friend reaches four in a row," + 117 | " or when all forty two slots are filled, ending in a stalemate." + 118 | " If you and your friend decide to play again, the first player typically goes first." + 119 | " The rules of the game are easy to learn, but difficult to master." + 120 | " That is the beauty of Connect Four. Now that you know the Connect 4" + 121 | " board game rules, now is the time to challenge everyone you know." + 122 | " No matter their age or skill level, they can play this game with you." + 123 | " Now that you understand the rules, share Connect Four with everyone around you." + 124 | " You’ll be glad you did.\n\n"); 125 | 126 | alert.show(); 127 | } 128 | 129 | private void exitGame() 130 | { 131 | Platform.exit(); // Closes the Virtual Machine 132 | System.exit(0); // Closes the Application 133 | } 134 | 135 | public static void main(String[] args) // Optional 136 | { 137 | launch(args); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Connect4Game/source/connectfour/game.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 49 | 58 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Core_Java_Certificate 06-06-2020.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Core_Java_Certificate 06-06-2020.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JAVA-FX CONNECT-4-GAME 2 | 3 | ![Java FX](https://img.shields.io/badge/-Finished-brightgreen.svg) 4 | 5 | >`C` 6 | >`E` 7 | >`R` 8 | >`T` 9 | >`I` 10 | >`F` 11 | >`I` 12 | >`C` 13 | >`A` 14 | >`T` 15 | >`E` 16 | 17 | 18 | ### I've created the Connect4Game using Java in IntelliJ IDEA. You can access the .JAR file in the repo! 19 | ### To run the APP, you must have Java [JDK v8] installed in your system. For a general overview, you can checkout the output screenshots included in the repo!! Thanks :santa: 20 | ```bash 21 | The Connect 4 Game Rules are easy to understand. In fact, it is in the name. 22 | To win *Connect Four*, all you have to do is to choose a color and then take turns 23 | dropping colored discs from the top into a *seven-column, six-row* vertically suspended grid. 24 | The pieces fall straight down, occupying the next available space within the column. 25 | The objective of this game is to *connect four* of your colored checker pieces in a row, 26 | much the same as tic tac toe. This can be done horizontally, vertically or diagonally. 27 | Each player will drop in one checker piece at a time. This will give you a chance to either build 28 | your row, or stop your opponent from getting four in a row. 29 | 30 | The game is over either when you or your friend reaches four in a row, 31 | or when all forty two slots are filled, ending in a stalemate. 32 | If you and your friend decide to play again, the first player typically goes first. 33 | The rules of the game are easy to learn, but difficult to master. That is the beauty of Connect Four. 34 | Now that you know the *Connect 4* board game rules, now is the time to challenge everyone you know. 35 | No matter their age or skill level, they can play this game with you. 36 | Now that you understand the rules, share *Connect Four* with everyone around you. 37 | You’ll be glad you did. 38 | ``` 39 | 40 | * **Main.java** `JAVA` 41 | * **Controller** `JAVA-fx` 42 | * **game** `FXML` 43 | 44 | ![Connect4](https://github.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/blob/master/Connect4Game/Output%20%2B%20C4%20%2B%202.png) 45 | 46 | # JAVA-FX Temperature-Converter-Tool 47 | 48 | ![Java FX](https://img.shields.io/badge/-Finished-brightgreen.svg) 49 | ### A simple Tool for *Temperature* Conversion using JAVA only. 50 | ### Open the JAR-file ⇨ Choose Conversion method ⇨ Enter Temperature ⇨ Get the Results :hatching_chick: 51 | 52 | ```bash 53 | Hi! I am Shreyansh, a developer focused on crafting 54 | great web/app experiences. Designing and Coding have been my passion since 55 | the days I started working with computers but I found myself into app 56 | design/development since 2019. 57 | Being an Engineer, 58 | I believe in using science to find creative practical solutions. 59 | Here is a Temperature Converter I created as a Beginner. 60 | My other hobbies includes Photography, Cooking & Painting. 61 | ``` 62 | 63 | * **MyMain.java** `JAVA` 64 | * **Controller** `JAVA-fx` 65 | * **app_layout** `FXML` 66 | 67 | ![C2F & F2C](https://github.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/blob/master/Temperature%20Converter%20Tool/C2F%20%2B%203.png) 68 | 69 | > :hash:#JAVA #Lockdown :hash:#FX #Jar-File :hash:#App #FXML :hash:#Dev 70 | 71 | #### :heavy_plus_sign::: Get Socialistic :::heavy_plus_sign: 72 | ✮ [Facebook](https://www.facebook.com/guru.shreyansh) 73 | ✮ [Instagram](https://www.instagram.com/guru_shreyansh) 74 | ✮ [Twitter](https://twitter.com/GURU_Shreyansh) 75 | 76 | @guru-shreyansh 77 | -------------------------------------------------------------------------------- /Temperature Converter Tool/C2F + 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Temperature Converter Tool/C2F + 1.png -------------------------------------------------------------------------------- /Temperature Converter Tool/C2F + 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Temperature Converter Tool/C2F + 2.png -------------------------------------------------------------------------------- /Temperature Converter Tool/C2F + 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Temperature Converter Tool/C2F + 3.png -------------------------------------------------------------------------------- /Temperature Converter Tool/C2F + 4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Temperature Converter Tool/C2F + 4.png -------------------------------------------------------------------------------- /Temperature Converter Tool/ReadME.MD: -------------------------------------------------------------------------------- 1 | # JAVA-FX Temperature-Converter-Tool 2 | 3 | ![Java FX](https://img.shields.io/badge/-Finished-brightgreen.svg) 4 | ### A simple Tool for *Temperature* Conversion using JAVA only. 5 | ### Open the JAR-file ⇨ Choose Conversion method ⇨ Enter Temperature ⇨ Get the Results :hatching_chick: 6 | 7 | ```bash 8 | Hi! I am Shreyansh, a developer focused on crafting 9 | great web/app experiences. Designing and Coding have been my passion since 10 | the days I started working with computers but I found myself into app 11 | design/development since 2019. 12 | Being an Engineer, 13 | I believe in using science to find creative practical solutions. 14 | Here is a Temperature Converter I created as a Beginner. 15 | My other hobbies includes Photography, Cooking & Painting. 16 | ``` 17 | 18 | * **MyMain.java** `JAVA` 19 | * **Controller** `JAVA-fx` 20 | * **app_layout** `FXML` 21 | 22 |

23 | 24 |

25 |

26 | 27 |

28 |

29 | 30 |

31 |

32 | 33 |

34 | 38 | > :hash:#JAVA #Lockdown :hash:#FX #Jar-File :hash:#App #FXML :hash:#Dev 39 | 40 | #### :heavy_plus_sign::: Get Socialistic :::heavy_plus_sign: 41 | ➧ [Facebook](https://www.facebook.com/guru.shreyansh) 42 | ➧ [Instagram](https://www.instagram.com/guru_shreyansh/) 43 | ➧ [Twitter](https://twitter.com/GURU_Shreyansh) 44 | 45 | @guru-shreyansh 46 | -------------------------------------------------------------------------------- /Temperature Converter Tool/Temperature Converter Tool.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Temperature Converter Tool/Temperature Converter Tool.jar -------------------------------------------------------------------------------- /Temperature Converter Tool/bin/Controller.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Temperature Converter Tool/bin/Controller.class -------------------------------------------------------------------------------- /Temperature Converter Tool/bin/MyMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guru-shreyansh/INTERNSHALA-Java-App-Developement-Projects/8950e10425722ade9b72aa3023e970daccf4bd34/Temperature Converter Tool/bin/MyMain.class -------------------------------------------------------------------------------- /Temperature Converter Tool/bin/app_layout.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 |