Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP2017 9017 Assignment
This assignment is worth 10% of your final assessment
Task Description
Your task is to create a multi-type linked list data structure and a program that interacts with it. Your
assignment is broken into three tasks that must be completed in order.
• The first part is the basic command syntax of the linked lists, creation, removal, viewing etc.
• The second part is modifying the lists in place, through insertion and deletion of elements.
• The third part is allowing lists to refer to each other in a nested pattern.
It is also recommended to read through the specification carefully. You should ensure that you create
test cases that cover a range of possible inputs before beginning to code.1 Make sure you identify and
test for edge cases.
Implementation Details
All commands are read through standard in, and all output is given through standard out.
Part 1: Basic Commands
For Part 1, your linked lists must support elements of the following types:
• int
• float
• char
• string
Your program should take in commands from stdin that will create and manage these multi-type
linked lists. The basic commands are:
1Even if you do it on pencil and paper, work through some examples to be sure you understand.
1
COMP2017 9017
• NEW - create a new list
• VIEW - view a specific list by its index
• TYPE - view a specific list by its index, printing out the types of each ele-
ment.
• VIEW ALL - print the number of lists and each list in order of creation
• REMOVE - remove a list
The index for each list should be 1 higher than the last created list’s index, starting from 0 for the first
list, regardless of how many lists have been removed.
Basic Examples
In the following examples, "> " denotes the following line as input. Your program must not print it to
stdout or read it from stdin. It is included in the formatting only as an indicator, to differentiate
the input from the output of the program.
Global input restrictions
and must be an integer, have no sign character, and
no whitespace 2.
Command keywords are delimited by exactly one (1) space character and should have no leading
and trailing whitespaces3. Be sure to replicate the formatting of these examples exactly, character by
character.
The NEW Command
This command takes in a number as input for the initial size of the list. It then reads in an initial value
for each element to initialise the list. 0 is a valid size, negative numbers are not. Lists are labelled
starting at 0 when they begin to exist, and the label always increments, even if a list is removed.
Imagine in the following section that 4 lists have already been created.
> NEW 5
> hello
> 1
> 2
> 3.14
> a
List 4: hello -> 1 -> 2 -> 3.14 -> a
Lists will only be considered as "created" after all lines of the input have been parsed and no error
occurs.
2element indices in INSERT may have an optional minus character
3except when INSERT ing, where the inserted value may contain whitespace. See type requirements
Systems Programming Page 2 of 15
COMP2017 9017
The VIEW Command
This command prints out the contents of the list at the given index.
> VIEW 4
hello -> 1 -> 2 -> 3.14 -> a
The TYPE Command
This command prints out the types of each element at the given list.
> TYPE 4
string -> int -> int -> float -> char
The VIEW ALL Command
This command prints out the current set of lists in index-increasing order.
> VIEW ALL
Number of lists: 3
List 0
List 3
List 4
The REMOVE Command
This command deletes a list, and prints out the current set of lists again in index-increasing order.
> REMOVE 3
List 3 has been removed.
Number of lists: 2
List 0
List 4
Invalid Commands
A command can be identified from a line if the line strictly begins with exactly the command keyword,
and is invalid if its invalid otherwise.
If a command is invalid in some way, print INVALID COMMAND: . For exam-
ple, when there is no List 4:
Systems Programming Page 3 of 15
COMP2017 9017
> REMOVE 4
INVALID COMMAND: REMOVE
If a command cannot be identified, use INPUT. For example:
> abracadabra
INVALID COMMAND: INPUT
It is up to you to find and prepare for edge cases.
Type Rules and Exceptions
There can be some ambiguity in certain cases for what a given input’s type is. The order for type
checking is as follows:
• integer
• float
• char
• string
Requirements for types are as follows:
• int can be negative, positive or zero (tests will also not exceed the maximum and minimum
value for an int type).
• float is the same except it will always have a decimal point.4
• float should also be printed to 2 decimal places, though they can be read in to any precision.
• char is any printable5 character in ascii as long as it is singular.
• string covers all other cases.