|
1 | | -# Java Advanced: Exception Handling & Collections |
| 1 | +# Java Advanced: Exception Handling & Collections |
2 | 2 |
|
3 | | -This repository showcases **advanced Java concepts**, focusing on **custom exceptions**, **robust error handling**, and **Java Collections Framework** usage. |
4 | | -It includes **five fully implemented tasks (Q1–Q5)** accompanied by code screenshots for clarity and reference. |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 📚 Overview |
| 11 | + |
| 12 | +This repository showcases **advanced Java concepts**, focusing on: |
| 13 | + |
| 14 | +- Custom exception handling |
| 15 | +- Collections framework usage |
| 16 | +- Stack implementation |
| 17 | +- HashMaps |
| 18 | +- Array exception management |
| 19 | + |
| 20 | +It contains **five structured tasks (Q1–Q5)**, each reinforced with code screenshots laid out in elegant grids. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 🛠️ Tech Stack |
| 25 | + |
| 26 | +| Language | Paradigm | Topics | |
| 27 | +|---------|----------|--------| |
| 28 | +| **Java 8+** | OOP, Exception Handling | Collections, Custom Exceptions, Stack, HashMap | |
5 | 29 |
|
6 | 30 | --- |
7 | 31 |
|
8 | 32 | ## 📁 Project Structure |
9 | 33 |
|
10 | 34 | ``` |
11 | | -├── AgeNotWithinRangeException.java # Custom exception for invalid student age |
12 | | -├── NameNotValidException.java # Custom exception for invalid name |
13 | | -├── Student.java # Student class using custom exceptions (Q1) |
14 | | -├── Voter.java # Voter class with age validation (Q2) |
15 | | -├── QuestionThree.java # Weekday array + exception handling (Q3) |
16 | | -├── QuestionFour.java # HashMap for student grades (Q4) |
17 | | -├── QuestionFive.java # Stack implementation using collections (Q5) |
18 | | -├── Screenshots/ |
19 | | -│ ├── 1.a.png 1.b.png 1.c.png 1.d.png |
20 | | -│ ├── 2.a.png 2.b.png |
21 | | -│ ├── 3.a.png 3.b.png 3.c.png |
22 | | -│ ├── 4.a.png 4.b.png 4.c.png 4.d.png |
23 | | -│ └── 5.png |
24 | | -└── README.md |
| 35 | +src/ |
| 36 | +├── AgeNotWithinRangeException.java |
| 37 | +├── NameNotValidException.java |
| 38 | +├── Student.java |
| 39 | +├── Voter.java |
| 40 | +├── QuestionThree.java |
| 41 | +├── QuestionFour.java |
| 42 | +├── QuestionFive.java |
| 43 | +└── screenshots/ |
| 44 | + ├── 1.a.png |
| 45 | + ├── 1.b.png |
| 46 | + ├── 1.c.png |
| 47 | + ├── 1.d.png |
| 48 | + ├── 2.a.png |
| 49 | + ├── 2.b.png |
| 50 | + ├── 3.a.png |
| 51 | + ├── 3.b.png |
| 52 | + ├── 3.c.png |
| 53 | + ├── 4.a.png |
| 54 | + ├── 4.b.png |
| 55 | + ├── 4.c.png |
| 56 | + ├── 4.d.png |
| 57 | + └── 5.png |
25 | 58 | ``` |
26 | 59 |
|
27 | 60 | --- |
28 | 61 |
|
29 | | -## 🧩 Task Overviews |
| 62 | +# 📝 Tasks Overview |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +# **Q1 — Student Management System (Custom Exceptions)** |
| 67 | + |
| 68 | +### ✔ Validates: |
| 69 | +- Age range (15–21) |
| 70 | +- Name characters (no digits/symbols) |
30 | 71 |
|
31 | | -### **Q1 — Student Management System (Custom Exceptions)** |
32 | | -Implements: |
33 | | -- `Student` class with: |
34 | | - - `rollNo`, `name`, `age`, `course` |
35 | | -- Custom exceptions: |
36 | | - - **AgeNotWithinRangeException** → age must be between **15–21** |
37 | | - - **NameNotValidException** → name must contain only letters |
38 | | -- Validates input using constructor-based rules. |
| 72 | +### ✔ Custom Exceptions: |
| 73 | +- `AgeNotWithinRangeException` |
| 74 | +- `NameNotValidException` |
39 | 75 |
|
40 | | -📸 **Screenshots:** |
41 | | - |
42 | | - |
| 76 | +### 📸 Screenshots |
| 77 | +| 1.a | 1.b | |
| 78 | +|---|---| |
| 79 | +|  |  | |
| 80 | + |
| 81 | +| 1.c | 1.d | |
| 82 | +|---|---| |
| 83 | +|  |  | |
43 | 84 |
|
44 | 85 | --- |
45 | 86 |
|
46 | | -### **Q2 — Voter Age Validation** |
47 | | -`Voter` class validates: |
48 | | -- Age must be **18 or above** |
49 | | -- Throws an exception for invalid age |
| 87 | +# **Q2 — Voter Age Validation** |
| 88 | + |
| 89 | +Throws exception if voter age < 18. |
50 | 90 |
|
51 | | -📸 **Screenshots:** |
52 | | - |
53 | | - |
| 91 | +### 📸 Screenshots |
| 92 | +| 2.a | 2.b | |
| 93 | +|---|---| |
| 94 | +|  |  | |
54 | 95 |
|
55 | 96 | --- |
56 | 97 |
|
57 | | -### **Q3 — Weekday Array + Exception Handling** |
58 | | -- Stores weekday names in an array (index 0 = Sunday) |
59 | | -- Accepts user index input |
60 | | -- Handles: |
61 | | - - **ArrayIndexOutOfBoundsException** |
62 | | - - Prints helpful error message |
| 98 | +# **Q3 — Weekday Array Handling** |
| 99 | + |
| 100 | +Handles `ArrayIndexOutOfBoundsException` for invalid day index. |
| 101 | + |
| 102 | +### 📸 Screenshots |
| 103 | +| 3.a | 3.b | |
| 104 | +|---|---| |
| 105 | +|  |  | |
63 | 106 |
|
64 | | -📸 **Screenshots:** |
65 | | - |
66 | | - |
67 | | - |
| 107 | +| 3.c | — | |
| 108 | +|---|---| |
| 109 | +|  | | |
68 | 110 |
|
69 | 111 | --- |
70 | 112 |
|
71 | | -### **Q4 — Student Grades Using HashMap** |
72 | | -Implements: |
| 113 | +# **Q4 — Student Grades with HashMap** |
| 114 | + |
| 115 | +Enables: |
73 | 116 | - Add student + grade |
74 | 117 | - Remove student |
75 | 118 | - Display grade by name |
76 | 119 |
|
77 | | -Uses Java **HashMap** to store key–value pairs. |
| 120 | +### 📸 Screenshots |
| 121 | +| 4.a | 4.b | |
| 122 | +|---|---| |
| 123 | +|  |  | |
78 | 124 |
|
79 | | -📸 **Screenshots:** |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
| 125 | +| 4.c | 4.d | |
| 126 | +|---|---| |
| 127 | +|  |  | |
84 | 128 |
|
85 | 129 | --- |
86 | 130 |
|
87 | | -### **Q5 — Stack Implementation Using Collections** |
88 | | -Implements: |
89 | | -- `push()` |
90 | | -- `pop()` |
91 | | -- `isEmpty()` |
| 131 | +# **Q5 — Stack Implementation (Collections)** |
92 | 132 |
|
93 | | -Built using a Java **Stack** or similar collection class. |
| 133 | +Implements push, pop, isEmpty using Java Collections. |
94 | 134 |
|
95 | | -📸 **Screenshot:** |
96 | | - |
| 135 | +### 📸 Screenshot |
| 136 | +| 5 | |
| 137 | +|---| |
| 138 | +|  | |
97 | 139 |
|
98 | 140 | --- |
99 | 141 |
|
100 | | -## ▶️ How to Run |
| 142 | +# ▶️ How to Run |
101 | 143 |
|
102 | | -### **1. Clone the Repository** |
103 | | -```bash |
104 | | -git clone https://github.com/thesoulseizure/task-4.git |
105 | | -cd task-4 |
106 | | -``` |
107 | | - |
108 | | -### **2. Compile All `.java` Files** |
109 | 144 | ```bash |
| 145 | +git clone https://github.com/TheComputationalCore/java-advanced-exceptions-collections.git |
| 146 | +cd java-advanced-exceptions-collections |
110 | 147 | javac *.java |
| 148 | +java Student # Q1 |
| 149 | +java Voter # Q2 |
| 150 | +java QuestionThree # Q3 |
| 151 | +java QuestionFour # Q4 |
| 152 | +java QuestionFive # Q5 |
111 | 153 | ``` |
112 | 154 |
|
113 | | -### **3. Run Any Task** |
114 | | - |
115 | | -| Task | Command | |
116 | | -|------|----------| |
117 | | -| Q1 — Student | `java Student` | |
118 | | -| Q2 — Voter | `java Voter` | |
119 | | -| Q3 — Weekday Array | `java QuestionThree` | |
120 | | -| Q4 — HashMap Grades | `java QuestionFour` | |
121 | | -| Q5 — Stack | `java QuestionFive` | |
122 | | - |
123 | 155 | --- |
124 | 156 |
|
125 | | -## 📌 Requirements |
126 | | -- **JDK 8 or higher** |
127 | | -- Any IDE or terminal that can compile and run Java programs |
| 157 | +# 📄 License |
128 | 158 |
|
129 | | ---- |
130 | | - |
131 | | -## 📄 License |
132 | | -This project is for **educational purposes** and demonstrates core Java error-handling & collections concepts. |
| 159 | +Distributed under the MIT License. |
133 | 160 |
|
134 | 161 | --- |
135 | 162 |
|
136 | | - |
|
0 commit comments