|
1 | 1 | # Java Advanced: Exception Handling & Collections |
2 | 2 |
|
3 | | - |
| 3 | +<div align="center"> |
| 4 | + |
| 5 | + |
4 | 6 |  |
5 | 7 |  |
6 | 8 |  |
7 | 9 |
|
| 10 | +</div> |
| 11 | + |
8 | 12 | --- |
9 | 13 |
|
10 | | -## 📚 Overview |
| 14 | +## 📌 Overview |
11 | 15 |
|
12 | | -This repository showcases **advanced Java concepts**, focusing on: |
| 16 | +This repository contains **advanced Java programs** demonstrating: |
13 | 17 |
|
14 | | -- Custom exception handling |
15 | | -- Collections framework usage |
16 | | -- Stack implementation |
17 | | -- HashMaps |
18 | | -- Array exception management |
| 18 | +- Custom Exception Handling |
| 19 | +- Collections Framework |
| 20 | +- Input Validation |
| 21 | +- Stack Implementation |
| 22 | +- HashMap Operations |
19 | 23 |
|
20 | | -It contains **five structured tasks (Q1–Q5)**, each reinforced with code screenshots laid out in elegant grids. |
| 24 | +It includes **five structured tasks (Q1–Q5)** supported by screenshots and organized code. |
21 | 25 |
|
22 | 26 | --- |
23 | 27 |
|
24 | | -## 🛠️ Tech Stack |
| 28 | +## 🗂️ Project Structure |
25 | 29 |
|
26 | | -| Language | Paradigm | Topics | |
27 | | -|---------|----------|--------| |
28 | | -| **Java 8+** | OOP, Exception Handling | Collections, Custom Exceptions, Stack, HashMap | |
| 30 | +| File | Description | |
| 31 | +|------|-------------| |
| 32 | +| `Student.java` | Student class with age + name validation using custom exceptions (Q1) | |
| 33 | +| `AgeNotWithinRangeException.java` | Thrown when age is outside 15–21 (Q1) | |
| 34 | +| `NameNotValidException.java` | Thrown when name contains invalid characters (Q1) | |
| 35 | +| `Voter.java` | Validates voter age (must be ≥ 18) (Q2) | |
| 36 | +| `QuestionThree.java` | Weekday array with index validation (Q3) | |
| 37 | +| `QuestionFour.java` | Student grades using HashMap (Q4) | |
| 38 | +| `QuestionFive.java` | Stack implementation using Collections (Q5) | |
| 39 | +| `screenshots/` | Complete screenshots of implementations | |
29 | 40 |
|
30 | 41 | --- |
31 | 42 |
|
32 | | -## 📁 Project Structure |
| 43 | +## 🖼️ Screenshots (Grid View) |
33 | 44 |
|
34 | | -``` |
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 |
58 | | -``` |
| 45 | +### **Q1 — Student Management (Exceptions)** |
| 46 | +<table> |
| 47 | +<tr> |
| 48 | +<td><img src="screenshots/1.a.png" width="250"></td> |
| 49 | +<td><img src="screenshots/1.b.png" width="250"></td> |
| 50 | +</tr> |
| 51 | +<tr> |
| 52 | +<td><img src="screenshots/1.c.png" width="250"></td> |
| 53 | +<td><img src="screenshots/1.d.png" width="250"></td> |
| 54 | +</tr> |
| 55 | +</table> |
59 | 56 |
|
60 | 57 | --- |
61 | 58 |
|
62 | | -# 📝 Tasks Overview |
| 59 | +### **Q2 — Voter Age Validation** |
| 60 | +<table> |
| 61 | +<tr> |
| 62 | +<td><img src="screenshots/2.a.png" width="250"></td> |
| 63 | +<td><img src="screenshots/2.b.png" width="250"></td> |
| 64 | +</tr> |
| 65 | +</table> |
63 | 66 |
|
64 | 67 | --- |
65 | 68 |
|
66 | | -# **Q1 — Student Management System (Custom Exceptions)** |
| 69 | +### **Q3 — Weekday Array Handling** |
| 70 | +<table> |
| 71 | +<tr> |
| 72 | +<td><img src="screenshots/3.a.png" width="250"></td> |
| 73 | +<td><img src="screenshots/3.b.png" width="250"></td> |
| 74 | +<td><img src="screenshots/3.c.png" width="250"></td> |
| 75 | +</tr> |
| 76 | +</table> |
67 | 77 |
|
68 | | -### ✔ Validates: |
69 | | -- Age range (15–21) |
70 | | -- Name characters (no digits/symbols) |
| 78 | +--- |
71 | 79 |
|
72 | | -### ✔ Custom Exceptions: |
73 | | -- `AgeNotWithinRangeException` |
74 | | -- `NameNotValidException` |
| 80 | +### **Q4 — Student Grades (HashMap)** |
| 81 | +<table> |
| 82 | +<tr> |
| 83 | +<td><img src="screenshots/4.a.png" width="250"></td> |
| 84 | +<td><img src="screenshots/4.b.png" width="250"></td> |
| 85 | +</tr> |
| 86 | +<tr> |
| 87 | +<td><img src="screenshots/4.c.png" width="250"></td> |
| 88 | +<td><img src="screenshots/4.d.png" width="250"></td> |
| 89 | +</tr> |
| 90 | +</table> |
75 | 91 |
|
76 | | -### 📸 Screenshots |
77 | | -| 1.a | 1.b | |
78 | | -|---|---| |
79 | | -|  |  | |
| 92 | +--- |
80 | 93 |
|
81 | | -| 1.c | 1.d | |
82 | | -|---|---| |
83 | | -|  |  | |
| 94 | +### **Q5 — Stack Implementation** |
| 95 | +<img src="screenshots/5.png" width="300"> |
84 | 96 |
|
85 | 97 | --- |
86 | 98 |
|
87 | | -# **Q2 — Voter Age Validation** |
88 | | - |
89 | | -Throws exception if voter age < 18. |
| 99 | +## 🧠 Task Breakdown |
90 | 100 |
|
91 | | -### 📸 Screenshots |
92 | | -| 2.a | 2.b | |
93 | | -|---|---| |
94 | | -|  |  | |
| 101 | +### **Q1 — Custom Exceptions in Student Class** |
| 102 | +- Validates: |
| 103 | + - Age between **15–21** |
| 104 | + - Name must NOT contain digits or symbols |
| 105 | +- Uses two custom exceptions: |
| 106 | + - `AgeNotWithinRangeException` |
| 107 | + - `NameNotValidException` |
95 | 108 |
|
96 | 109 | --- |
97 | 110 |
|
98 | | -# **Q3 — Weekday Array Handling** |
| 111 | +### **Q2 — Voter Age Validation** |
| 112 | +Ensures voter age is **≥ 18**, otherwise throws a custom exception. |
99 | 113 |
|
100 | | -Handles `ArrayIndexOutOfBoundsException` for invalid day index. |
101 | | - |
102 | | -### 📸 Screenshots |
103 | | -| 3.a | 3.b | |
104 | | -|---|---| |
105 | | -|  |  | |
| 114 | +--- |
106 | 115 |
|
107 | | -| 3.c | — | |
108 | | -|---|---| |
109 | | -|  | | |
| 116 | +### **Q3 — Weekday Array** |
| 117 | +- Stores weekday names in an array. |
| 118 | +- Handles: |
| 119 | + - Invalid index |
| 120 | + - `ArrayIndexOutOfBoundsException` |
110 | 121 |
|
111 | 122 | --- |
112 | 123 |
|
113 | | -# **Q4 — Student Grades with HashMap** |
114 | | - |
115 | | -Enables: |
| 124 | +### **Q4 — Student Grades (HashMap)** |
| 125 | +Operations: |
116 | 126 | - Add student + grade |
117 | 127 | - Remove student |
118 | | -- Display grade by name |
119 | | - |
120 | | -### 📸 Screenshots |
121 | | -| 4.a | 4.b | |
122 | | -|---|---| |
123 | | -|  |  | |
| 128 | +- Print grade by name |
124 | 129 |
|
125 | | -| 4.c | 4.d | |
126 | | -|---|---| |
127 | | -|  |  | |
| 130 | +Uses: |
| 131 | +```java |
| 132 | +HashMap<String, Integer> |
| 133 | +``` |
128 | 134 |
|
129 | 135 | --- |
130 | 136 |
|
131 | | -# **Q5 — Stack Implementation (Collections)** |
132 | | - |
133 | | -Implements push, pop, isEmpty using Java Collections. |
| 137 | +### **Q5 — Integer Stack (Collections)** |
| 138 | +Implements: |
| 139 | +- `push()` |
| 140 | +- `pop()` |
| 141 | +- `isEmpty()` |
134 | 142 |
|
135 | | -### 📸 Screenshot |
136 | | -| 5 | |
137 | | -|---| |
138 | | -|  | |
| 143 | +Uses: |
| 144 | +```java |
| 145 | +Stack<Integer> |
| 146 | +``` |
139 | 147 |
|
140 | 148 | --- |
141 | 149 |
|
142 | | -# ▶️ How to Run |
| 150 | +## ▶️ How to Run |
143 | 151 |
|
144 | 152 | ```bash |
145 | 153 | git clone https://github.com/TheComputationalCore/java-advanced-exceptions-collections.git |
146 | 154 | cd java-advanced-exceptions-collections |
147 | 155 | javac *.java |
148 | | -java Student # Q1 |
149 | | -java Voter # Q2 |
150 | | -java QuestionThree # Q3 |
151 | | -java QuestionFour # Q4 |
152 | | -java QuestionFive # Q5 |
| 156 | + |
| 157 | +# Run tasks: |
| 158 | +java Student # Q1 |
| 159 | +java Voter # Q2 |
| 160 | +java QuestionThree # Q3 |
| 161 | +java QuestionFour # Q4 |
| 162 | +java QuestionFive # Q5 |
153 | 163 | ``` |
154 | 164 |
|
155 | 165 | --- |
156 | 166 |
|
157 | | -# 📄 License |
| 167 | +## 📄 License |
158 | 168 |
|
159 | | -Distributed under the MIT License. |
160 | | - |
161 | | ---- |
| 169 | +This project is licensed under the **MIT License**. |
162 | 170 |
|
0 commit comments