COL 106 Assignment 1



In this assignment you have to use both linked lists and arrays to store data about students, hostels, courses, etc. You must not use any integer constant in your code.

You may only use external packages java.util.Iterator and* for this assignment.

· First, implement the following LinkedList interface, which uses a Position interface:

public interface Position<T> {// Supports any class T
   public T value();          // Return value at position
   public Position<T> after();// Returns the position after this position in its list

public interface LinkedList<T> {// Supports any class T
   public Position<T> add(T e);              // Add element e to this list, returns it position in the list
   public Iterator<Position<T>>  positions();// Returns an iterator for all positions in the list
   public int  count();                      // Returns the number of elements in the list

A student has three entities: department, hostel and courses. In this assignment, you are required to maintain at least these three linked lists to manage these entities: allHostels includes all hostels, allDepartments includes all departments and allCourses includes all courses. In addition, each element in the lists allHostels, allDepartments, allCourses itself should maintain lists that includes all students in that hostel, department, or course, respectively.
· In order to organize these entities, use interface Entity:

public interface Entity { // Entities Classes Hostel, Dept, and Course all have this functionality. 
   public String name();                 // Returns this  entity’s name
   public Iterator studentList();        // Returns all students of this entity

· You may implement classes Hostel, Department, and Course, which are derived from Entity. You must also implement interface Student:

public interface Student {
   public String name();               // Returns student's name
   public String entryNo();            // Returns student's entry number
   public String hostel();             // Returns student's hostel name
   public String department();         // Returns student's department name
   public Iterator courseList();       // Returns an iterator for all courses for this student

· Finally, implement a public class Assignment1, with a static main that has two phases. The main program takes as command line argument two strings, each string is a file name. The first file (student record file) contains data about the students and the second (student query file) contains some queries to process.

In the first phase, the program reads information per student from the specified student record file, inserting the information in the respective linked lists (e.g., allHostels, allDepartments, allCourses), updating all data structures.

Student record file will contain record details of student in this order: entry number, name, department, hostel and classes registered for. These string names are separated. (See examples later.) Every line contains one record of one student. The student record file will hence act as your source of student information.

In the second phase, your program will read student query file, which contains one query per line. For each query, your program must output the correct answer to System.out, one answer per line in the specified format. Three types of queries have to be supported. Their formats and their explanation are given below:

COUNT entityname1 entityname2 entityname3
COUNT is a keyword, followed by any number of entities (given as strings). This query should result in output of an integer: the total number of students which are common to all provided entities. This intersection should be implemented by using suitable arrays. For example, if a single entity is listed, the answer is simply the number of students in that entity. In other words, if the query line lists COUNT cse, the output is the number of students in cse. Any unrecognized entity name should result in a count of 0.

Note that the type of entity will be inferred from an entity name. Entity names are unique. In other words, if a department is named cse, no course or hostel would be named cse. But there will be extra credit for handling non-unique names. In such case, the query should count all students that are common to all entities named cse.

INFO student
INFO is the keyword. List information about student with the given entry number or the given name: Entry number, Name, Department, Hostel and classes, each separated by space, in that order.

SHARE studententrynumber entityname
SHARE is the keyword. Provide space separated list of the entry numbers of all students who share the given entity with him or her.


Example student record file and student query file have been provided. The required solution for the included query file is given in the third file. Your output must match this format to be counted correct.

Submission instructions

Submission will be at moodle. Link will be provided in due course.

Please ensure that you follow the following set of instructions meticulously while submitting the assignment on Moodle. Also, please note that in case of deviation from this procedure will render your submission faulty, and your assignment might not be evaluated at all by the script. Please follow these steps:

  1. On eclipse, by default, all your source files (.java files) are saved into a directory called "src" inside your project. You have to compress this directory (to zip format) and rename the zip file in this format:
    Example: If your entry number is 2012CSZ8019, the zip file should be named It should expand to a directory called src, which contains all your .java files. Please make sure that you follow exactly this naming format.
  2. Next, convert the zip file to base64 format. On any linux system, you can do this easily by issuing the following command on the terminal :
       base64 >
    This will create a file with the same name with a b64 extension appended at the end.
  3. Upload this b64 file on moodle and submit it (in the "Submission" section). After Submission, there is an option of "Evaluate" in the "Edit" section. Click on "Evaluate". On the right side of the window, you will get information about the submission status. On clicking the "Evaluate" link, you should see a script running and producing an output of your codes' performance against the standard set of test cases that we supply internally for the assessment. A dialog box will show you the messages on how your codes performed against the benchmarks that we provided.
        Important notes