This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

ch9.6-7 issue

By: fathershuma on Mar 17th, 2013  |  syntax: None  |  size: 3.75 KB  |  views: 126  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. public interface Priority {
  3.  
  4.     public void setPriority();
  5.     public int getPriority();
  6. }
  7. import java.io.*;
  8. import java.util.*;
  9. import java.util.GregorianCalendar;
  10. public class ToDoList {
  11.     int nextYear;
  12.     int nextDay;
  13.     int nextMonth;
  14.     String Descrip;
  15.     GregorianCalendar date;
  16.     int Pri;
  17.     int Year;
  18.     int Month;
  19.     int Day;
  20.  
  21.     ArrayList <ToDoList> taskList= new ArrayList<ToDoList>();
  22.     Task k= new Task(Descrip, date, Pri);
  23.     public void go(){
  24.         try
  25.           {retrieveTasks();}
  26.  
  27.         catch(IOException e)
  28.             {e.printStackTrace();}
  29.         }
  30.  
  31.     void retrieveTasks() throws IOException{
  32.         Scanner fileScanner= new Scanner(new File("Data/tasks.txt"));
  33.         while(fileScanner.hasNext()){
  34.             String Descrip= fileScanner.next();
  35.             //System.out.println(Descrip);
  36.             int nextYear= fileScanner.nextInt();
  37.             //System.out.println(nextYear);
  38.             int nextMonth= fileScanner.nextInt();
  39.             //System.out.println(nextMonth);
  40.             int nextDay= fileScanner.nextInt();
  41.             //System.out.println(nextDay);
  42.             int Pri= fileScanner.nextInt();
  43.             //System.out.println(Pri);
  44.             GregorianCalendar d= new GregorianCalendar(nextYear, nextMonth, nextDay);
  45.             System.out.println(d);
  46.         }}
  47. }
  48. import java.io.*;
  49. import java.util.*;
  50. import java.util.GregorianCalendar;
  51.  
  52. public class TaskManager {
  53.     int nextYear;
  54.     int nextMonth;
  55.     int nextDay;
  56.     GregorianCalendar date;
  57.  
  58.     ArrayList <ToDoList> taskList= new ArrayList<ToDoList>();
  59.     public static void main(String[] args){
  60.     ToDoList t= new ToDoList();
  61.     t.go();
  62.     }
  63. }
  64.  
  65. public class taskCompare{
  66.      public int compare(Task t1, Task t2){
  67.         return t1.getTask().compareTo(t2.getTask());
  68.     }
  69. }
  70. import java.util.GregorianCalendar;
  71. import java.io.*;
  72. import java.util.*;
  73.  
  74. public class Task implements Comparable, Priority{
  75.     public String Descrip;
  76.     public GregorianCalendar dueDate;
  77.     public int Pri;
  78.     public int p;
  79.     public Task t;
  80.     public String s;
  81.     public GregorianCalendar calDate;
  82.     public GregorianCalendar date;
  83.  
  84.     ArrayList <ToDoList> taskList= new ArrayList<ToDoList>();
  85.  
  86.     public Task(String Descrip, GregorianCalendar date, int Pri){
  87.         this.Descrip= Descrip;
  88.         this.date= calDate;
  89.         this.Pri= Pri;
  90.     }
  91.  
  92.     public void setDueDate(GregorianCalendar date){
  93.         date= calDate;
  94.     }
  95.  
  96.     public int compareTo(Task t){
  97.         return calDate.compareTo(t.getDueDate());
  98.     }
  99.  
  100.     public GregorianCalendar getDate(){
  101.         return calDate;
  102.     }
  103.  
  104.     private GregorianCalendar getDueDate() {
  105.         return calDate;
  106.     }
  107.  
  108.     public void setTask(){
  109.         this.Descrip=Descrip;
  110.     }
  111.  
  112.     public String getTask(){
  113.         return s;
  114.     }
  115.  
  116.     public void setPriority() {
  117.         Pri= Pri;
  118.     }
  119.  
  120.     public int getPriority() {
  121.         return Pri;
  122.     }
  123.  
  124.     public String toString() {
  125.         return Descrip + " is due " + dateString()+" with a priority of "+Pri;
  126.     }
  127.  
  128.     public String dateString() {
  129.         return calDate.getTime().toString(); }
  130. }
  131. public class GregorianCalendar extends ToDoList {
  132.     String nextYear;
  133.     String nextMonth;
  134.     String nextDay;
  135.     int Year;
  136.     int Month;
  137.     int Day;
  138.     GregorianCalendar date;
  139.     public GregorianCalendar(int Year, int Month, int Day){
  140.         this.Year= Year;
  141.         this.Month=Month;
  142.         this.Day= Day;
  143.         GregorianCalendar date= new GregorianCalendar(Year, Month, Day);
  144.         //System.out.println(Year+" "+Month+" "+Day);
  145.     }
  146.  
  147. }
  148. data in file being scanned in:
  149. take-out-trash 2013 3 19 8
  150. program-in-Java 2013 3 16 2
  151. study-for-java-final 2013 4 27 1
clone this paste RAW Paste Data