Advertisement
Guest User

CALENDAR

a guest
Sep 2nd, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 1.55 KB | None | 0 0
  1. note
  2.     description: "Summary description for {CALENDAR}."
  3.     author: ""
  4.     date: "$Date$"
  5.     revision: "$Revision$"
  6.  
  7. class
  8.     CALENDAR
  9.  
  10. create
  11.     initialize
  12.  
  13. feature
  14.  
  15.     entries: ARRAY[ENTRY]
  16.     i: INTEGER
  17.     i1: INTEGER
  18.     i2: INTEGER
  19.     initialize(a:INTEGER)
  20.         do
  21.             create entries.make_empty
  22.         end
  23.  
  24.     create_entry( new_date: TIME; new_owner: PERSON; new_subject: STRING; new_place: STRING ): ENTRY
  25.         do
  26.  
  27.             create Result.initialize(new_date, new_owner, new_subject, new_place )
  28.  
  29.             entries.force (Result, entries.count + 1)
  30.  
  31.         end
  32.  
  33.     edit_subject ( e: ENTRY; new_subject : STRING )
  34.         do
  35.  
  36.             from i:= 1 until i > entries.count loop
  37.  
  38.                 if entries[i] = e then
  39.  
  40.                     entries[i].initialize (entries[i].date, entries[i].owner, new_subject, entries[i].place)
  41.  
  42.                 end
  43.  
  44.                 i := i + 1
  45.  
  46.             end
  47.  
  48.         end
  49.  
  50.     edit_date( e: ENTRY; new_date : TIME )
  51.         do
  52.  
  53.             from i:= 1 until i > entries.count loop
  54.  
  55.                 if entries[i] = e then
  56.  
  57.                     entries[i].initialize (new_date, entries[i].owner, entries[i].subject, entries[i].place)
  58.  
  59.                 end
  60.  
  61.                 i := i + 1
  62.  
  63.             end
  64.  
  65.         end
  66.  
  67.  
  68.  
  69.     get_owner_name( e: ENTRY ) : STRING
  70.         do
  71.             Result := e.owner.name
  72.         end
  73.  
  74.  
  75.  
  76.     in_conflict ( e1: ENTRY; e2 : ENTRY ) : BOOLEAN
  77.         do
  78.  
  79.             from i:= 1 until i > entries.count loop
  80.  
  81.                 if entries[i] = e1 then
  82.                     i1 := i
  83.                 end
  84.  
  85.                 if entries[i] = e2 then
  86.                     i2 := i
  87.                 end
  88.  
  89.                 i := i + 1
  90.  
  91.             end
  92.  
  93.             if entries[i1].date = entries[i2].date or entries[i1].place = entries[i2].place then
  94.                 Result := True
  95.             else
  96.                 Result := False
  97.             end
  98.  
  99.         end
  100.  
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement