home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / RB3641.ZIP / EX2 / TDLIST.ST < prev    next >
Text File  |  1991-12-19  |  4KB  |  119 lines

  1.        Exercise 2 - solutions
  2.  
  3.         ToDoList ( * This is the step by step instruction file ** )
  4.  
  5.        " In Class Hierarchy Browser select  
  6.         the class 'OrderedCollection' and
  7.         select 'Add Subclass' in  'Classes' menu.
  8.         Write the name of the class (ToDoList)  in the entry field. 
  9.         In the input are, insert one  instance variable names to
  10.         this new class. The variable name is sortKey."
  11.  
  12.        " You should create a method to add the To-Do item.
  13.         Name it 'addItem:'. The 'addItem' method has a parameter,
  14.         that is an item to be add."
  15.  
  16.         "To install the following method, evaluate with Do It:"
  17.  
  18.           (File pathName: 'ex2\addItem.mth') fileIn; close.
  19.  
  20.  
  21.      "This is a test case for the addItem:anItem method 
  22.       of ToDoList class"
  23.  
  24.       | tmpList tmpItem|
  25.         tmpItem:= ToDoItem new.
  26.         tmpItem type:'personal';
  27.               deadline:'99.12.31';
  28.               description:'something';
  29.               priority:1;
  30.               completed: false .
  31.        tmpList:= ToDoList new.
  32.        tmpList addItem:tmpItem.
  33.        tmpList inspect.
  34.  
  35.  
  36.     "This is a test case for saving and loading the object
  37.      using the ObjectFiler"
  38.  
  39.       "Save the To-Do List object
  40.        Evaluate these expressions with DoIt
  41.        After doing this, a dialog box comes out.
  42.        You can select the name of file to save the object
  43.        using the dialog box"
  44.  
  45.    | tmpList tmpItem|
  46.        tmpItem:= ToDoItem new.
  47.        tmpItem type:'personal';
  48.               deadline:'99.12.31';
  49.               description:'something';
  50.               priority: 1;
  51.               completed: false .
  52.        tmpList:= ToDoList new.
  53.        tmpList addItem:tmpItem.
  54.        ObjectFiler dump: tmpList.
  55.  
  56.       "Load the To-Do List object.
  57.        Evaluate these expressions with DoIt
  58.        After doing this, a dialog box comes out.
  59.        You can select the name of file to load the object
  60.        using the dialog box"
  61.    
  62.            (ObjectFiler load) inspect.
  63.  
  64.       "Next is to load the object to the To-Do List object."
  65.  
  66.       | tmpList|
  67.           tmpList := ObjectFiler load  .
  68.           tmpList inspect.
  69.  
  70.        "If you know where the file is, 
  71.         for example 'FILEDOBJ.OBJ',
  72.         you can do as follows.
  73.         In this case, a dislog box doesn't come out"
  74.  
  75.        | tmpList|
  76.         tmpList := ObjectFiler 
  77.            loadFromPathName:'C:\STVPM13\EX2\FILEDOBJ.OBJ'.
  78.         tmpList inspect.
  79.  
  80.    "To install the readList method, 
  81.     evaluate the following with DoIt:"
  82.  
  83.     (File pathName: 'ex2\readList.mth') fileIn; close.
  84.  
  85.    "To install the writeLst method, 
  86.      evaluate the following with DoIt:"
  87.  
  88.     (File pathName: 'ex2\writeLst.mth') fileIn; close.
  89.  
  90.    "This is a test case for the sortList method 
  91.     of ToDoList class"
  92.  
  93.    | tmpList tmpItem1 tmpItem2|
  94.       tmpItem1:= ToDoItem new.
  95.       tmpItem2:= ToDoItem new.
  96.       tmpItem1 type:'personal';
  97.               deadline:'99.12.31';
  98.               description:'something';
  99.               priority: 2;
  100.               completed: false .
  101.       tmpItem2 type:'meeting';
  102.               deadline:'91.12.31';
  103.               description:'something';
  104.               priority: 1;
  105.               completed: false .
  106.      tmpList:= ToDoList new.
  107.      tmpList addItem:tmpItem1.
  108.      tmpList addItem:tmpItem2.
  109.      tmpList sortList:'type'.
  110.      tmpList sortList;
  111.                 inspect.
  112.  
  113.    "To install the ToDoList class, 
  114.      evaluate the following with DoIt:"
  115.  
  116.     (File pathName: 'ex2\todolist.cls') fileIn; close.
  117.  
  118. "************ end of exercises ***********************"
  119.