CSE3001/CSE5040: Modula-3 Project

Part I, due Friday, March 19, 1999. Part II, due Friday, March 26, 1999.

Project description

In this project for cse3001/cse5040 you are to write a Modula-3 program using generic modules to solve a problem. The project is divided into two parts.

You may work together in groups of up to two people for the two parts As long as you work with someone different than on the previous project.

Part I

On an account in the Harris lab perform the following steps.
  1. Create a directory partI and partI/src
          mkdir partI partI/src
          
  2. Copy the following files into partI/src:
          cp ~ryan/public_html/m3/programs/north/src/Input.m3 partI/src
          cp ~ryan/public_html/m3/programs/north/src/*LinkedList.[im][g3] partI/src
          
  3. For purposes of this project, edit and modify only Input.m3 and not the other files.
          chmod -w *LinkedList.[im][g3]
          
  4. In the directory partI/src create a file m3makefile with the following lines.
          import(libm3)
          implementation(Input)
          program(input)        % name of the executable file will be "input"
          
  5. Make sure /software/modula-3/bin and /software/gnu/bin are in your path. Try printenv PATH or which m3build. If it is not there, then (assuming csh or tcsh is your shell) issue the command:
          setenv PATH /software/modula-3/bin/:/software/gnu/bin/:$PATH; rehash
          
    NB. Like all software in the directory /software the Modula-3 compiler is for a Sun Solaris machine (not the SGIs).
  6. In the directory partI invoke the command m3build. (Ignore the compiler warnings.)
  7. In the directory partI invoke the command SOLgnu/input and verify the program works as expected by typing in some cities.
  8. Modify the m3makefile by adding the following lines:
          generic_module(LinkedList)
          module(TextLinkedList)
          
    As the module Input will now also import TextLinkedList these lines must come before the line implementation(Input).
  9. Modify the program Input.m3 to add each city (once) into a linked list of cities. (This is the hard part; the adding just takes one statement, but the "once" part requires writing a boolean function.)
  10. Verify the program works correctly, perhaps by printing the list back out.
  11. Be sure your name is in the comments of the program. From the directory partI/src submit your program Input.m3 by issuing the following command
          ~ryan/bin/mfiles "ryan@cs" "part I" Input.m3
          

A list of submissions for part I is maintained by hand (and so may not be current).

Part II

Extend part I to write a Modula-3 program to read two sets of data. The first set consists of many pairs of cities:
city1  city2
The first city of the pair is given to be south of the second city. The second set of data also consists of many pairs of cities. For each pair in the second set of data, the program is to print one of the following lines of output:
city1 is south of city2.
city1 is north of city2.
The relative position of city1 and city2 is unknown.

The relation "is south of" is a transitive relationship, so if city1 is south of city2 and city2 is south of city3, then city1 is south of city3. You may assume that the input is consistent, that is, there will be no information that indicates a city is north of itself.

Sample Input and Output

For the following input:
Melbourne    DaytonaBeach
DaytonaBeach Jacksonville
Orlando   Jacksonville
#
Melbourne Jacksonville
Tampa Melbourne
Jacksonville Orlando
Orlando DaytonaBeach
#
the output should be
Melbourne is south of Jacksonville.
The relative position of Tampa and Melbourne is unknown.
Jacksonville is north of Orlando.
The relative position of Orlando and DaytonaBeach is unknown.

Turning it in

Your executable file must be named main. From the src directory submit all your program files all at once with the same command:
~ryan/bin/mfiles "ryan@cs" "part II" m3makefile ...
Use the modules LinkedList and TextLinkedList in your program, but do not send me them back to me.

A list of submissions for part II is maintained by hand (and so may not be current). Only the last submission from a login counts. All previous submissions are ignored.

Hint

It is likely that you will need to create two more modules (interface and implementation files). One module will be a second generic instatiation of the linked list module. Follow the example of Both the interface and implementation files are one line long. The second module is likely to be a module containing the type used in the linked list. This type must be named T (as we want to use it to instantiate the linked list). Suppose that these modules are called X and XLinkedList. You will need to add to your m3makefile the following lines
module(X)
module(XLinkedList)
The order of the lines in the m3makefile are important.

For those that need help solving the problem a psuedo-code outline of the solution is available.

References

Modula-3 Src

Ryan Stansifer <ryan@cs.fit.edu>
Document location: http://www.cs.fit.edu/~ryan/cse5040/proj-www.html
Last modified: Tue Mar 23 14:36:24 EST 1999