Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To Do List DATA ABSTRACTION: The class might be Item (the thing to do), and it may have some fields like name , status (done/not

To Do List

DATA ABSTRACTION: The class might be Item (the thing to do), and it may have some fields like name , status (done/not done), and dueDate. It would need setters and getters for those fields (for example, you must have something like setName and getName to access and change the value in the name field). All methods would be specified using REQUIRES/MODIFIES/EFFECTS appropriately. It would also need some internal implementation, so in this case it could be something like determining whether the item is past its due date. if you're trying to do this option -- remember to read the answers not the question code!! If you use any of the answers, credit the code. - Yes you can use some of the posted code as long as you credit it in your solution using a comment line)

Instead of just calling everything from Main, in the ui package, make a new package called "model", (move your Item class into there), and make a second class "ToDoList". From your ui/Main.main construct the new ToDoList, and get the program going from there. Put all the code that was once in Main.main into a new method (ToDoList.run()), and move all the helper methods from the original class into your ToDoList class.

TEST THE DATA ABSTRACTION: You would also include a class "TestToDoList" that tests the ToDoList class methods, and a TestItem class, that has tests of the Item methods, ensuring they are behaving properly.

Can you show the example ?

this is my main and class that I have written

MAIN

package ui;

import java.util.Scanner;

public class Main { public static void main(String []args) { Scanner input = new Scanner(System.in); Todo todolists = new Todo(); int user = 0; // System.out.println("[1] Enter the item text"); // System.out.println("[2] which item would you like to cross off"); // System.out.println("[3] Enter the item text"); // while(true) { System.out.println("[1] Enter the item text"); System.out.println("[2] which item would you like to cross off"); System.out.println("[3] Show items"); System.out.println("[4] To termiante the program"); System.out.print("USER = "); user = input.nextInt(); if(user ==1) { System.out.print("Enter the To Do List: "); String todo = input.next(); todolists.add(todo);

}else if (user == 2){ if(todolists.Count()>0) { todolists.Displayitem(); System.out.print("Which Item would you like to cross off :"); int index = input.nextInt(); todolists.crossout(index-1); }else { System.out.print("ALL DONE"); }

}else if(user ==3) { todolists.Displayitem(); }else { break; } } } }

CLASS

package ui;

import java.util.Scanner; import java.util.ArrayList;

public class Todo {

private ArrayList todolist; public Todo() { todolist = new ArrayList(); } //add to add thing in the ArrayList public void add(String item) { todolist.add(item); } //to delete thing from list public void crossout(int index) { if(index>=0&&index

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions