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

java ch 9.6-7 problem

By: fathershuma on Mar 17th, 2013  |  syntax: Java  |  size: 3.83 KB  |  views: 49  |  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.             nextYear=Year;
  45.             nextMonth= Month;
  46.             nextDay= Day;
  47.             GregorianCalendar d= new GregorianCalendar(Year, Month, Day);
  48.             System.out.println(d);
  49.         }}
  50. }
  51. import java.io.*;
  52. import java.util.*;
  53. import java.util.GregorianCalendar;
  54.  
  55. public class TaskManager {
  56.     int nextYear;
  57.     int nextMonth;
  58.     int nextDay;
  59.     GregorianCalendar date;
  60.  
  61.     ArrayList <ToDoList> taskList= new ArrayList<ToDoList>();
  62.     public static void main(String[] args){
  63.     ToDoList t= new ToDoList();
  64.     t.go();
  65.     }
  66. }
  67.  
  68. public class taskCompare{
  69.      public int compare(Task t1, Task t2){
  70.         return t1.getTask().compareTo(t2.getTask());
  71.     }
  72. }
  73. import java.util.GregorianCalendar;
  74. import java.io.*;
  75. import java.util.*;
  76.  
  77. public class Task implements Comparable, Priority{
  78.     public String Descrip;
  79.     public GregorianCalendar dueDate;
  80.     public int Pri;
  81.     public int p;
  82.     public Task t;
  83.     public String s;
  84.     public GregorianCalendar calDate;
  85.     public GregorianCalendar date;
  86.  
  87.     ArrayList <ToDoList> taskList= new ArrayList<ToDoList>();
  88.  
  89.     public Task(String Descrip, GregorianCalendar date, int Pri){
  90.         this.Descrip= Descrip;
  91.         this.date= calDate;
  92.         this.Pri= Pri;
  93.     }
  94.  
  95.     public void setDueDate(GregorianCalendar date){
  96.         date= calDate;
  97.     }
  98.  
  99.     public int compareTo(Task t){
  100.         return calDate.compareTo(t.getDueDate());
  101.     }
  102.  
  103.     public GregorianCalendar getDate(){
  104.         return calDate;
  105.     }
  106.  
  107.     private GregorianCalendar getDueDate() {
  108.         return calDate;
  109.     }
  110.  
  111.     public void setTask(){
  112.         this.Descrip=Descrip;
  113.     }
  114.  
  115.     public String getTask(){
  116.         return s;
  117.     }
  118.  
  119.     public void setPriority() {
  120.         Pri= Pri;
  121.     }
  122.  
  123.     public int getPriority() {
  124.         return Pri;
  125.     }
  126.  
  127.     public String toString() {
  128.         return Descrip + " is due " + dateString()+" with a priority of "+Pri;
  129.     }
  130.  
  131.     public String dateString() {
  132.         return calDate.getTime().toString(); }
  133. }
  134. public class GregorianCalendar extends ToDoList {
  135.     String nextYear;
  136.     String nextMonth;
  137.     String nextDay;
  138.     int Year;
  139.     int Month;
  140.     int Day;
  141.     GregorianCalendar date;
  142.     public GregorianCalendar(int Year, int Month, int Day){
  143.         this.Year= Year;
  144.         this.Month=Month;
  145.         this.Day= Day;
  146.         GregorianCalendar date= new GregorianCalendar(Year, Month, Day);
  147.         //System.out.println(Year+" "+Month+" "+Day);
  148.     }
  149.  
  150. }
  151.  
  152. data in text file to read with Scanner:
  153. take-out-trash 2013 3 19 8
  154. program-in-Java 2013 3 16 2
  155. study-for-java-final 2013 4 27 1
clone this paste RAW Paste Data