Question

In: Computer Science

I am having trouble figuring out how to To-Do list using java. Can anyone guide me...

I am having trouble figuring out how to To-Do list using java. Can anyone guide me through the steps for achieving this?

Solutions

Expert Solution

CODE

import java.util.ArrayList;

class Task {

private String message;

private boolean done;

public Task(String message, boolean done) {

super();

this.message = message;

this.done = done;

}

public String getMessage() {

return message;

}

public void setMessage(String message) {

this.message = message;

}

public boolean isDone() {

return done;

}

public void setDone(boolean done) {

this.done = done;

}

}

class ToDoList {

private ArrayList<Task> tasks;

public ToDoList() {

this.tasks = new ArrayList<>();

}

public void addTask(String message) {

Task t = new Task(message, false);

tasks.add(t);

}

public void markDone(String message) {

for(Task t : tasks) {

if (message.equalsIgnoreCase(t.getMessage())) {

t.setDone(true);

}

}

}

public void displayPendingTasks() {

for (Task t : tasks) {

if (!t.isDone()) {

System.out.println(t.getMessage());

}

}

}

public void displayCompletedTasks() {

for (Task t : tasks) {

if (t.isDone()) {

System.out.println(t.getMessage());

}

}

}

}

public class Main {

public static void main(String[] args) {

ToDoList list = new ToDoList();

list.addTask("Laundry");

list.addTask("Pick up groceries");

list.markDone("laundry");

System.out.println("List of pending tasks: ");

list.displayPendingTasks();

System.out.println("List of completed tasks: ");

list.displayCompletedTasks();

}

}


Related Solutions

Can you balance these redox equations? I am having trouble figuring out the process of adding...
Can you balance these redox equations? I am having trouble figuring out the process of adding extra products to make them work. ClO3- + Cl- -----> Cl2 + ClO2- Cr2O72- + C2O42- -----> Cr3+ + CO2
I'm having trouble figuring out the constraints to this problem. I know that I am maximizing...
I'm having trouble figuring out the constraints to this problem. I know that I am maximizing 55x + 45y, however the variables are throwing me off. I only need help on question #1 as it would be a great help to understanding the rest of what the questions are asking. The problem is as follows: NorCal Outfitters manufactures a variety of specialty gear for outdoor enthusiasts. NorCal has decided to begin production on two new models of crampons: the Denali...
I am having difficulties with figuring out the formulas for this this question. Is there a...
I am having difficulties with figuring out the formulas for this this question. Is there a walk-through for this? You are the manager of a monopoly that sells a product to two groups of consumers in different parts of the country. Group 1’s elasticity of demand is -2, while group 2’s is -3. Your marginal cost of producing the product is $30. a. You are a monopolist. b. You compete against one other firm in a Cournot oligopoly. c. You...
These are the correct answers but I am having difficulty figuring out how these figures were...
These are the correct answers but I am having difficulty figuring out how these figures were reached. On March ​1, 2018​, Nailtique Nail Salons issued $450,000 of 15​-year, 5 percent bonds payable. The bonds were sold for $432,000. The bonds pay interest each August 31 and February 28​, and any discount or premium is amortized using​ straight-line amortization. Requirement 1. Fill in the blanks to complete each statement. a. Nailtique Nail Salons' bonds are priced at (express the price as...
I have figured out this assignment, but I am having a hard time figuring out the...
I have figured out this assignment, but I am having a hard time figuring out the extra credit, Thanks! Creating a Rectangle class We have created a representation of a rectangle in C++ and extended it to create multiple representation's of rectangles. Classes can simplify that process considerably. In this assignment, your task is to convert the representation of a rectangle we created earlier in the semester to a Rectangle class. The Rectangle class shall consist of the following: The...
This is Python coding question, and topic is loop Can anyone help me figuring these out?...
This is Python coding question, and topic is loop Can anyone help me figuring these out? (Please do not use build in function) Thanks. 1. Write a program that prints your name 100 times to the screen. 2. Write a program that takes a string s and an integer n as parameters and prints the string s a total of in n times(once per line) 3. Write a for loop that prints all the integers from 3141 to 5926, skipping...
If anyone could simplify this for me. I'm having trouble understanding the material and I just...
If anyone could simplify this for me. I'm having trouble understanding the material and I just need a keep it simple stupid approach Discuss the various non influential as well as influential investments that company may have on their financial statements. Also compare and contrast how they are treated/recorded on the companies financial statements.
I am having difficulty figuring out the rest of this problem, primarily with regards to calculating...
I am having difficulty figuring out the rest of this problem, primarily with regards to calculating APIC and Retained earnings for Stock Dividends. Also, I need assistance with the fourth problem, how to calculate the total value of shareholders' equity. Could you please help show me how to solve? Accounting for Share Transactions The shareholders' equity section of the consolidated balance sheet of Wilson Industries appeared as follows at the beginning of the year: Shareholders' Equity Class A common stock,...
Hello! I am having trouble starting this program in Java. the objective is as follows: "...
Hello! I am having trouble starting this program in Java. the objective is as follows: " I will include a text file with this assignment. It is a text version of this assignment. Write a program that will read the file line by line, and break each line into an array of words using the tokenize method in the String class. Count how many words are in the file and print out that number. " my question is, how do...
TCP client and server using C programming I am having trouble on how to read in...
TCP client and server using C programming I am having trouble on how to read in the IP adress and port number from the terminal Example: Enter IP address: 127.0.0.1 Enter Port Number: 8000 in both client and server code. How do can I make I can assign the Ip address and port number using the example above. the error I get is that the client couldn't connect with the server whenever i get the port number from the user...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT