The Definitions File
Pretend that you know a student who is taking IB Standard Level Computer Science.
Further pretend that the student studied for their tests and wanted an easy
way to view all of the definitions that they needed to learn. Clearly this student
would write a program to help them with these functions.
There is a text file (defn.txt) that contains data about "definitions".
A definition consists of:
- an integer that represents the unit
- an integer that represents the lesson in the unit
- a String that represents Gor or IB (IB stands for official IB definition).
- a String that represents the word
- a String that represents the definition
- To do:
- create an object to hold the definitions.
- create an array to hold the definition objects. The array should be about
250 spaces. Create a variable to mark the end point in the data. We are going
to leave some space at the end to insert new things.
Methods:
Level 1-3
- open - this method opens the file definition.txt and reads
it into the array. It returns -1 if there were too many items in the file
to load into the array (put nothing in the array in this case) and the size
of the array if everything goes well.
- print_list - prints the entire array. returns nothing.
- save - saves any changes to the file. returns nothing.
Level 4
- search - takes a word and returns its definition.
Level 5
- insert - allows you to insert a new definition at the end.
It returns the new size of the array.
- delete - takes the word that you want to delete and removes
it. It returns the new size of the array.
Level 6-7
- sort_definition - takes the list and sorts it by definition
- sort_unit - takes the list and sorts it first by unit and
the by lesson number.