Here's your Telegram post for Day 30!
---
π **Congratulations on Reaching Day 30!** π
You've made incredible progress in just thirty days, diving into Java fundamentals! π Now it's time to consolidate all your learning with a final project. How about building a simple *Command-Line To-Do List Manager*? π It's a fantastic way to apply your understanding of classes, objects, methods, `ArrayList`s, and user input. Let's review some core concepts and get you thinking!
Hereβs a quick look at a basic `Task` class and how you might manage a list of them:
```java
import java.util.ArrayList;
import java.util.List;
// Represents a single To-Do item
class Task {
private String description;
private boolean isCompleted;
public Task(String description) {
this.description = description;
this.isCompleted = false; // By default, a new task is not completed
}
public String getDescription() {
return description;
}
public boolean isCompleted() {
return isCompleted;
}
public void markCompleted() {
this.isCompleted = true;
}
@Override
public String toString() {
return "[" + (isCompleted ? "β " : "β³") + "] " + description;
}
}
// Main class to demonstrate To-Do list management
public class Day30Review {
public static void main(String[] args) {
List<Task> myTasks = new ArrayList<>(); // Use ArrayList for dynamic size
System.out.println("--- Initial To-Do List ---");
myTasks.add(new Task("Learn Java basics"));
myTasks.add(new Task("Start final project idea"));
myTasks.add(new Task("Review OOP concepts"));
for (Task task : myTasks) {
System.out.println(task);
}
System.out.println("n--- Updating Task Status ---");
// Mark the first task as completed
if (!myTasks.isEmpty()) {
myTasks.get(0).markCompleted();
System.out.println("Marked '" + myTasks.get(0).getDescription() + "' as completed.");
}
System.out.println("n--- Updated To-Do List ---");
for (Task task : myTasks) {
System.out.println(task);
}
}
}
```
Output example:
```
--- Initial To-Do List ---
[β³] Learn Java basics
[β³] Start final project idea
[β³] Review OOP concepts
--- Updating Task Status ---
Marked 'Learn Java basics' as completed.
--- Updated To-Do List ---
[β ] Learn Java basics
[β³] Start final project idea
[β³] Review OOP concepts
```
### Small Challenge:
Your challenge for your To-Do List Manager:
1. **Add User Input:** Implement `Scanner` to allow users to add new tasks.
2. **Remove Tasks:** Create a method that allows users to remove tasks by their index in the list.
3. **List by Status:** Add functionality to display *only* completed tasks or *only* pending tasks.
Ready to build something awesome? You've got this! πͺ Don't forget to share your progress! #JavaLearning #Day30 #FinalProject #CodingChallenge
---
---
π **Congratulations on Reaching Day 30!** π
You've made incredible progress in just thirty days, diving into Java fundamentals! π Now it's time to consolidate all your learning with a final project. How about building a simple *Command-Line To-Do List Manager*? π It's a fantastic way to apply your understanding of classes, objects, methods, `ArrayList`s, and user input. Let's review some core concepts and get you thinking!
Hereβs a quick look at a basic `Task` class and how you might manage a list of them:
```java
import java.util.ArrayList;
import java.util.List;
// Represents a single To-Do item
class Task {
private String description;
private boolean isCompleted;
public Task(String description) {
this.description = description;
this.isCompleted = false; // By default, a new task is not completed
}
public String getDescription() {
return description;
}
public boolean isCompleted() {
return isCompleted;
}
public void markCompleted() {
this.isCompleted = true;
}
@Override
public String toString() {
return "[" + (isCompleted ? "β " : "β³") + "] " + description;
}
}
// Main class to demonstrate To-Do list management
public class Day30Review {
public static void main(String[] args) {
List<Task> myTasks = new ArrayList<>(); // Use ArrayList for dynamic size
System.out.println("--- Initial To-Do List ---");
myTasks.add(new Task("Learn Java basics"));
myTasks.add(new Task("Start final project idea"));
myTasks.add(new Task("Review OOP concepts"));
for (Task task : myTasks) {
System.out.println(task);
}
System.out.println("n--- Updating Task Status ---");
// Mark the first task as completed
if (!myTasks.isEmpty()) {
myTasks.get(0).markCompleted();
System.out.println("Marked '" + myTasks.get(0).getDescription() + "' as completed.");
}
System.out.println("n--- Updated To-Do List ---");
for (Task task : myTasks) {
System.out.println(task);
}
}
}
```
Output example:
```
--- Initial To-Do List ---
[β³] Learn Java basics
[β³] Start final project idea
[β³] Review OOP concepts
--- Updating Task Status ---
Marked 'Learn Java basics' as completed.
--- Updated To-Do List ---
[β ] Learn Java basics
[β³] Start final project idea
[β³] Review OOP concepts
```
### Small Challenge:
Your challenge for your To-Do List Manager:
1. **Add User Input:** Implement `Scanner` to allow users to add new tasks.
2. **Remove Tasks:** Create a method that allows users to remove tasks by their index in the list.
3. **List by Status:** Add functionality to display *only* completed tasks or *only* pending tasks.
Ready to build something awesome? You've got this! πͺ Don't forget to share your progress! #JavaLearning #Day30 #FinalProject #CodingChallenge
---