Question

CIS 1068 Assignment 8 Warm Up with Objects Due: Wednesday, March 25 70 points (+ up to 15 extra credit) The purpose of this aHoneyDoList Implement a class HoneyDoList, which is used to manage a collection of Task. It should contain the following privEclipse project. Create each class as you have all semester, by right- clicking on the package icon under the src directory,

Please Implement this code using Java Eclipse.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Task.java

import java.time.LocalDateTime;

public class Task{
   private String name;
   private int priority;
   private int estMinsToComplete;
   private LocalDateTime whenDue;
  
   public Task(String name,int prio,LocalDateTime due,int est) {
       this.name=name;
       this.priority=prio;
       this.estMinsToComplete=est;
       this.whenDue=due;
   }
   public Task(String name,int prio,LocalDateTime due) {
       this.name=name;
       this.priority=prio;
       this.whenDue=due;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public int getPriority() {
       return priority;
   }

   public void setPriority(int priority) {
       this.priority = priority;
   }

   public int getEstMinsToComplete() {
       return estMinsToComplete;
   }

   public void setEstMinsToComplete(int estMinsToComplete) {
       this.estMinsToComplete = estMinsToComplete;
   }

   public LocalDateTime getWhenDue() {
       return whenDue;
   }

   public void setWhenDue(LocalDateTime whenDue) {
       this.whenDue = whenDue;
   }
  
   public String toString() {
       return "name "+name+" priority "+priority+" estMinstoComplete "+estMinsToComplete+" when due "+whenDue;
   }
  
   public void increasePriority(int amount) {
       if(amount>0)
           this.priority+=amount;
   }
   public void decreasePriority(int amount) {
       if(amount>=this.priority)
           this.priority=0;
       else
           this.priority-=amount;
   }
   public boolean overdue() {
       if(LocalDateTime.now().compareTo(this.whenDue)>0) {
           return true;
       }
       return false;
   }
  
  
}

//////////////////////////////////////////////////

HoneyDoList.java

public class HoneyDoList{
   private Task tasks[];
   private int numTasks;
   private int INITIAL_CAPACITY;
  
   public HoneyDoList() {
       tasks=new Task[INITIAL_CAPACITY];
       numTasks=0;
   }
   public String toString() {
       String s="";
       for(int i=0;i<numTasks;i++) {
           if(tasks[i]!=null) {
               s+=tasks[i].toString()+"\n";
           }
       }
       return s;
   }
   public int find(String name) {
       int i=0;
       for(i=0;i<numTasks;i++) {
           if(tasks[i].getName().equalsIgnoreCase(name))
               return i;
       }
       return -1;
   }
   public void addTask(Task task) {
       //Task t=new Task("new task",10,LocalDateTime.now(),120);
       if(tasks.length==numTasks) {
           Task tt[]=new Task[tasks.length+1];
           int i=0;
           for(i=0;i<tasks.length;i++)
           {
               tt[i]=tasks[i];
           }
           tt[i]=task;
           numTasks++;
           tasks=tt;
       }
       else {
           tasks[numTasks]=task;
           numTasks++;
       }
   }
   public int totalTime() {
       int total=0;
       for(int i=0;i<numTasks;i++) {
           total+=tasks[i].getEstMinsToComplete();
       }
       return total;
   }
   public int shortestTime() {
       int min=999;
       if(numTasks==0)
           return -1;
       for(int i=0;i<numTasks;i++) {
           if(tasks[i].getEstMinsToComplete()>min)
               min=tasks[i].getEstMinsToComplete();
       }
       return min;
   }
   public Task completeTask(int index) {
       if(index<0||index>=numTasks)
           return null;
       Task t=tasks[index];
       for(int i=index;i<numTasks-1;i++) {
           tasks[i]=tasks[i+1];
       }
       numTasks--;
       return t;
   }
   public Task[] overdueTasks() {
       Task t[]=new Task[tasks.length];
       int j=0;
       for(int i=0;i<numTasks;i++) {
           if(tasks[i].overdue()==true)
               t[j++]=tasks[i];
       }
       return t;
   }
}

//////////////////////////////////////////

TaskMain.java


public class TaskMain{
   public static void main(String args[]) {
       Task t=new Task("finish work",3,LocalDateTime.now(),180);
       System.out.println(t.toString());
      

   }
}

///////////////////////////////////////////

HoneyDoListMain.java

public class HoneyDoListMain{
   public static void main(String args[]) {
  
       HoneyDoList honeydo=new HoneyDoList();
       System.out.println(honeydo);
      
       honeydo.addTask(new Task("take aspirin",1,LocalDateTime.of(2019,3,23,13,0)));
       System.out.println(honeydo);
      
       System.out.println(honeydo.shortestTime());
   }
}

<terminated Test (Java Application) C:\Program FilesVava\jdk1.8.0_211\bin\javaw.exe (Mar 25, 2020, 4:36:27 PM) name finish wo

<terminated Test (Java Application) C:\Program FilesVava\jdk1.8.0_211\bin\javaw.exe (Mar 25, 2020, 4:36:27 PM) name finish work priority 3 estMinstoComplete 180 when due 2020-03-25T16:36:29.019 name take aspirin priority 1 estMinstoComplete when due 2019-03-23T13:00 999

Add a comment
Know the answer?
Add Answer to:
Please Implement this code using Java Eclipse. CIS 1068 Assignment 8 Warm Up with Objects Due:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table...

    IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table class to hold employees and their ID numbers. You'll create an employee class to hold each person's key (id number) and value (name). Flow of the main program: Create an instance of your hash table class in your main method. Read in the Employees.txt file and store the names and ID numbers into Employee objects and store those in your hash table using the...

  • The following code must be written and run with no errors in java eclipse Description of...

    The following code must be written and run with no errors in java eclipse Description of the code to be written: A resistor is an electronic part colour-coded with three coloured bands to indicate its resistance value. This program returns the resistance of a Resistor object instantiated with three Strings, representing the three colour bands of a real resistor. Start by creating an abstract class 'AbstractResistor' that implements the Comparable interface. This class should have the following three private methods:...

  • Write the following program in Java using Eclipse. A cash register is used in retail stores...

    Write the following program in Java using Eclipse. A cash register is used in retail stores to help clerks enter a number of items and calculate their subtotal and total. It usually prints a receipt with all the items in some format. Design a Receipt class and Item class. In general, one receipt can contain multiple items. Here is what you should have in the Receipt class: numberOfItems: this variable will keep track of the number of items added to...

  • code must be in java. Assignment 5 Purpose In this assignment, you will implement a class...

    code must be in java. Assignment 5 Purpose In this assignment, you will implement a class hierarchy in Java. Instructions The class hierarchy you will implement is shown below account Package Account manager Package SavingAccount CheckingAccount AccountManager The descriptions of each class and the corresponding members are provided below. Please note that the Visibility Modifiers (public, private and protected) are not specified and you must use the most appropriate modifiers Class AccountManager is a test main program. Create it so...

  • Task #3 Arrays of Objects 1. Copy the files Song java (see Code Listing 7.1), Compact...

    Task #3 Arrays of Objects 1. Copy the files Song java (see Code Listing 7.1), Compact Disc.java (see Code Listing 7.2) and Classics.txt (see Code Listing 7.3) from the Student Files or as directed by your instructor. Song.java is complete and will not be edited. Classics.txt is the data file that will be used by Compact Disc.java, the file you will be editing. 2. In Compact Disc.java, there are comments indicating where the missing code is to be placed. Declare...

  • Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer...

    Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer Data: Area Codes Assume you work for a company that tracks customer information, including name, gender and phone numbers Your company has a file called customers.txt which contains the following information: Jiming Wu F 4082123458 James Brown M 8315678432 Leanna Perez F 4087654433 Xing Li M 8313214555 Stacey Cahill O 8312123333 Mohammed Abbas M 4083134444 Kumari Chakrabarti F 4086667777 Shakil Smith M 4082123333 Jung...

  • In Java, Implement a class MyArray as defined below, to store an array of integers (int)....

    In Java, Implement a class MyArray as defined below, to store an array of integers (int). Many of its methods will be implemented using the principle of recursion. Users can create an object by default, in which case, the array should contain enough space to store 10 integer values. Obviously, the user can specify the size of the array s/he requires. Users may choose the third way of creating an object of type MyArray by making a copy of another...

  • This Individual Assignment is a set of three problems. The first is a recursion "warm up"...

    This Individual Assignment is a set of three problems. The first is a recursion "warm up" exercise, and the second two are QuickSort variations. The "warm up" should be implemented as a static method in your main App class and the second two will use additional classes (as instructed below). All three problems should be included in the same NetBeans project (exported to ZIP as usual). ----------------- All of your classes should be properly encapsulated, follow all proper coding conventions...

  • Need assistance with this problem. This is for a java class and using eclipse. For this...

    Need assistance with this problem. This is for a java class and using eclipse. For this assignment we’ll be doing problems 21.3 and 21.4 from your textbook. Problem 21.3 asks you to write a generic method that removes duplicate items from an ArrayList. This should be fairly straightforward. Problem 21.4 asks you to implement insertion sort within a generic method. Insertion sort is described in detail on pages 250-252 of your textbook. You can write your two methods in a...

  • **** ITS MULTI-PART QUESTION. PLEASE MAKE SURE TO ANSWER THEM ALL. SOLVE IT BY JAVA. ****...

    **** ITS MULTI-PART QUESTION. PLEASE MAKE SURE TO ANSWER THEM ALL. SOLVE IT BY JAVA. **** *** ALSO MAKE SURE IT PASS THE TESTER FILE PLEASE*** Often when we are running a program, it will have a number of configuration options which tweak its behavior while it's running. Allow text completion? Collect anonymous usage data? These are all options our programs may use. We can store these options in an array and pass it to the program. In its simplest...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT