Jan 24, 2026
## Chapter 21: Mini Projects (The "Don't Copy-Paste" List)
I’ve seen students copy-paste these from the internet. **Don't do that.** You won't learn a thing. Try to build these yourself, even if your code looks "ugly" at first. Ugly code that works is better than perfect code you didn't write.
### Project 1: The "Classroom Helper" (Student Marks Manager)
**Goal:** Create a program that takes a list of students and their marks. It should calculate the class average and tell you who failed (below 35).
- **Teacher’s Tip:** Use an `ArrayList<Student>`. Don't use two separate arrays for names and marks—it’s a nightmare to keep them in sync.
- **Common Mistake:** Forgetting to handle the case where the list is empty (you can't divide by zero when calculating the average!).
### Project 2: The "Word Finder" (File Word Counter)
**Goal:** Ask the user for a filename, read that file, and count how many words are in it.
- **Teacher’s Tip:** Use `content.split("\s+")` to split the text into words. That weird `\s+` just means "any amount of space."
- **Common Mistake:** Not using a `try-catch` block. What if the user types a filename that doesn't exist? Your program will crash!
### Project 3: The "Money Tracker" (Basic Expense Manager)
**Goal:** A small console app where you can add an expense (like "Pizza - $10"), see the total spent, and save the list to a file.
- **Teacher’s Tip:** Save each expense on a new line in the file like this: `Pizza:10`. It makes it easier to read back later.
- **Common Mistake:** Trying to write everything in the `main` method. Break it down into methods like `addExpense()`, `showTotal()`, etc.
### Project 4: The "Number Guesser" (Logic & Randomness)
**Goal:** The computer picks a random number between 1 and 100, and you have to guess it. The computer tells you "Too high" or "Too low."
- **Teacher’s Tip:** Use `java.util.Random` to pick the number and a `while` loop to keep the game going until you guess correctly.
- **Common Mistake:** Not checking if the user typed something that isn't a number (like "hello"). Use `Scanner.hasNextInt()` to be safe.
### Project 5: The "Mini Library" (The OOP Masterclass)
**Goal:** Create a system with `Book` and `Member`. Members can borrow books.
- **Teacher’s Tip:** This is where you use **Inheritance**. Maybe you have
different types of books (E-books, Physical books).
- **Common Mistake:** Allowing a member to borrow a book that is already borrowed. Always check the "status" of the book first!
## Appendix: The Teacher’s Quick Reference
Don't try to memorize these. Just know they exist so you can look them up when you need them.
### 1. Speed Cheatsheet (Time Complexity)
Think of this as: *"How much will this slow down my computer if the data gets huge?"*
- **One Loop (`for i to n`):** Linear speed. If you have 100 items, it takes 100 steps.
- **Double Loop (Nested):** Dangerous! If you have 100 items, it takes 10,000 steps ($100 times 100$).
- **HashMap/HashSet:** Super fast. Almost instant regardless of size.
### 2. Must-Know Java Tools
These are the "Power Tools" in your toolbox:
- **`String` & `StringBuilder`:** Use `StringBuilder` if you are changing a string 1000 times in a loop.
- **`ArrayList`:** Your go-to for lists.
- **`HashMap`:** Perfect for "Key-Value" data (like Phonebook: Name -> Number).
- **`Files`:** The easiest way to read/write files in modern Java.
## Final Advice (From My Heart to Yours)
Look, I’ve seen hundreds of students learn Java. The ones who become great engineers aren't the ones who never fail. They are the ones who:
1. **Don't run behind "Advanced" topics.** If your loops and methods are weak, "Spring Boot" or "Microservices" will just confuse you. Build a strong foundation first.
2. **Write code daily.** Even if it's just 30 minutes. It's like learning a language—if you don't speak it, you forget it.
3. **Explain it to a friend.** If you can't explain your code to someone else, you don't truly understand it yet.
**Final Word:** Java is just a tool to solve problems. Don't get lost in the syntax. Focus on the logic, keep building things, and don't be afraid of errors—they are just your computer's way of teaching you.
See you in the professional world! 🚀