CS 222 Spring 2016

Course Query System, Part I

Due: May 01, 23:55.

Language: Java

Submission:

  • DO NOT include package names
  • Check your file encoding. It should be UTF-8
  • Commit your code to SVN

Context: You are given the courses offered for one semester in CodeHero Academy. Your task is to write a program to query these courses accordign to some criteria. The requirements for this new software are:

  1. Parse the raw data that represents courses offered into a data structure in memory
  2. Allow users to list (these mush be unique and sorted)
    • Instructors
    • Rooms
    • Subject names (of courses)
    • Courses nos
  3. Allow users to query courses by specific
    • Room
    • Day
    • Instructor
    • Course No
    • Subject name
    • Courses that start in the morning (starting time range: 08:40 - 11:40)

As an example, the output of querying all courses that are offered at room CK:FEAS: G16 is provided here.

Course information

Course information has been provided to you as a JSON file here. In Java you’ll need to use a JSON API to parse the contents of the file.

Task 1 - Object formation

Read the JSON data and convert it to in-memory CoursesOffered object that holds Course objects. You will certainly need to create more objects to hold information of a course: room, instructor..etc. You’re expected to figure it out yourself. Examine the JSON data carefully for this.

In this part, you have to write your own CoursesOffered and Course classes (and any other class that is needed to hold information about a course).

Task 2 - User interaction

Provide a console-based interaction for the user to run queries on your data. Your interface should allow the user to:

  1. Allow users to list (these mush be unique and sorted)
    • Instructors
    • Rooms
    • Subject names (of courses)
    • Courses nos
  2. Get specific information about the courses. This information should include:
    1. Room
    2. Day
    3. Instructor
    4. Course No
    5. Subject Name
    6. Courses that start in the morning (starting time range: 08:40 - 11:40)

The design of your CLI is left to you this time. Please make sure it’s easily understood and interacted with.

All of this information should be calculated at query time from your objects and not be hard-coded into your source. Your program should be console-driven, that is it should start up, prompt the user for input, and be able to perform any combination of valid operations without exiting. Also, be careful to check for invalid input. The JSON data should be parsed once at the beginning of the program. After you construct your objects, do NOT use the JSON data to calculate the answer to a user query; all those calculations must be done through the objects.

Task 3

Refactor your code. In addition to appropriate naming, clean and short and well-defined functions, apply what you have learnt from formatting lecture. Make sure that you don’t have any code smells in your code.

Hints

Watch this video.

Demo

Watch this video. This is the demo of a similar assignment assigned on previous semesters (CSAir).

Grading

  • Functionality
    • Parsing JSON data, construction of the objects: 18
    • User-interaction queries: 10
  • Clean code
    • Names: 8
    • Functions: 15
    • Formatting: 15

Penalties:

  • Parsing JSON data each time user queries: -20
  • Bad CLI design: -10