├── README.md ├── Pattern.class ├── Project 1 ├── Game.class ├── Game2.class ├── DeepToStringDemo.java └── Game.java ├── Pattern.java └── PatternX.java /README.md: -------------------------------------------------------------------------------- 1 | # Java 2 | Clear all your Java Doubts 3 | -------------------------------------------------------------------------------- /Pattern.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/Java/HEAD/Pattern.class -------------------------------------------------------------------------------- /Project 1/Game.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/Java/HEAD/Project 1/Game.class -------------------------------------------------------------------------------- /Project 1/Game2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/Java/HEAD/Project 1/Game2.class -------------------------------------------------------------------------------- /Pattern.java: -------------------------------------------------------------------------------- 1 | public class Pattern { 2 | public static void main(String[] args) { 3 | int n = 6; 4 | pattern(n); 5 | } 6 | 7 | static void pattern(int n){ 8 | for (int i = 0; i < n ; i++) { 9 | for (int j = 0; j <= i; j++) { 10 | System.out.print("* "); 11 | } 12 | System.out.println(); 13 | } 14 | for (int i = 0; i < n ; i++) { 15 | for (int j = i; j < n; j++) { 16 | System.out.print("* "); 17 | } 18 | System.out.println(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Project 1/DeepToStringDemo.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | import java.util.concurrent.ForkJoinPool; 3 | 4 | public class DeepToStringDemo { 5 | public static void main(String[] args) { 6 | 7 | int[][] arr = { 8 | { 1, 2, 3 }, 9 | { 4, 5, 6 }, 10 | { 7, 8, 9 } 11 | }; 12 | 13 | System.out.println(Arrays.toString(arr[0])); 14 | // for (int i = 0; i < arr[0].length; i++) { 15 | // for (int j = 0; j < arr.length; j++) { 16 | // System.out.print(arr[i][j] +" "); 17 | // } 18 | // System.out.println(); 19 | // } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PatternX.java: -------------------------------------------------------------------------------- 1 | class PatternX { 2 | public static void main(String[] args) { 3 | pattern(7); 4 | } 5 | 6 | static void pattern(int n) { 7 | int c = n * 2 - 1; 8 | for (int i = 0; i < c; i++) { 9 | for (int j = 0; j < c; j++) { 10 | if (i == j || j == c-i-1) { 11 | System.out.print("*"); 12 | } else { 13 | System.out.print(" "); 14 | } 15 | } 16 | System.out.println(); 17 | } 18 | } 19 | 20 | // * * 21 | // * * 22 | // * * 23 | // * * 24 | // * * 25 | // * 26 | // * * 27 | // * * 28 | // * * 29 | // * * 30 | // * * 31 | 32 | } -------------------------------------------------------------------------------- /Project 1/Game.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | public class Game { 5 | 6 | // Function to implement the game 7 | static int game(char you, char computer) { 8 | 9 | if (you == 's' && computer == 'p') 10 | return 0; 11 | 12 | else if (you == 'p' && computer == 's') 13 | return 1; 14 | 15 | if (you == 's' && computer == 'z') 16 | return 1; 17 | 18 | else if (you == 'z' && computer == 's') 19 | return 0; 20 | 21 | if (you == 'p' && computer == 'z') 22 | return 0; 23 | 24 | else if (you == 'z' && computer == 'p') 25 | return 1; 26 | 27 | return -1; 28 | } 29 | 30 | // Driver Code 31 | public static void main(String[] args) { 32 | Scanner sc = new Scanner(System.in); 33 | 34 | char computer = ' '; 35 | 36 | Random random = new Random(); 37 | int n = random.nextInt(100) % 100; 38 | 39 | if (n < 33) 40 | computer = 's'; 41 | 42 | else if (n > 33 && n < 66) 43 | computer = 'p'; 44 | else 45 | computer = 'z'; 46 | 47 | System.out.println("\n\n\n\nEnter s for STONE, p for PAPER and z for SCISSOR\n"); 48 | 49 | // input from the user 50 | char you = sc.next().charAt(0); 51 | 52 | // Function Call to play the game 53 | int result = game(you, computer); 54 | 55 | if (result == -1) { 56 | System.out.println("\n\nGame Draw!\n"); 57 | } else if (result == 1) { 58 | System.out.println("\n\nWow! You have won the game!\n"); 59 | } else { 60 | System.out.println("\n\nOh! You have lost the game!\n"); 61 | } 62 | System.out.println("You choose : " + you + "\nComputer choose : " + computer + "\n"); 63 | 64 | } 65 | } 66 | --------------------------------------------------------------------------------