KIT107


Pages: 10
Questions: 7
UNIVERSITY OF TASMANIA
EXAMINATIONS FOR DEGREES AND DIPLOMAS
November 2019
KIT107 Programming
First and Only Paper
Ordinary Examination
Time Allowed: THREE (3) hours
Reading Time: FIFTEEN (15) minutes
Instructions:
There is a total of 180 marks available. You are required to answer ALL
SEVEN (7) questions — attempt ALL FOUR (4) questions from Section A,
BOTH OF THE TWO (2) questions from Section B, and THE ONE (1)
question from Section C.
Answers for each section should be written in a DIFFERENT book.
Question 3. (Assessing ILOs: 1 and 3)
A Robot has a male or female voice and can speak when spoken to by a Human. It can
be created (by advising its Voice), and can also have its speaking volume
increased/decreased by a specified amount from its current value (initially 25) to a value
not less than 0 and not greater than 50 by a Human, or examined for its value.
a. Produce a UML diagram for the Robot ADT as described above.
[4 marks]
b. Convert the UML diagram into a Java interface.
[4 marks]
c. Convert the UML diagram into a C header file.
[4 marks]
Question 4. (Assessing ILOs: 2 and 3)
a. Explain polymorphism of values and, using examples, how this is implemented
in each of Java and C.
[6 marks]
b. Explain how a function pointer aids genericity in C and give code which
includes an example of the use of a function pointer.
[6 marks]
-5- KIT107 Programming
Continued…
SECTION B — LONG ANSWER QUESTIONS
Answer ALL questions available in Section B. All questions in Section B are of equal
value. Each question is worth 51 marks. This section is worth 102 marks, or 56.7% of
the examination.
Question 5. (Assessing ILOs: 1, 2, and 3)
Marbles! Large ones, medium-sized ones, small ones. Cats-eye ones, plain ones, swirly
ones. Glass ones, wooden ones, plastic ones. Old ones, new ones. Marbles!
A Toy Company has asked you to develop an app to manage a club’s collection of
marbles, to add marbles to the collection, and to remove marbles from the collection.
See part (e) ii for details on required functionality.
There are an unknown number of members and membership changes all the time with
KIT107留学生作业代做、C++编程语言作业调试
new members added weekly. All marbles belonging to the same member should be
stored in the computerised collection together for ease of access. There will be at most
1000 marbles per member.
Each marble should have its diameter in millimetres (a double), content (an
enumeration), material (an enumeration), and age (a bool) stored. The collection of
marbles for each member should be stored in increasing order of diameter (smallest
first).
Given the following enumerations:
typedef enum {plain, swirled, cats_eye} content;
typedef enum {glass, wooden, plastic} material;
A marble may be defined as follows:
struct marble_int {
double diameter;
content look;
material made_of;
bool new;
};
typedef struct marble_int *marble;
and you may assume the existence of those types and the following types and functions:
void init_marble(marble *mp, double d, content c, material
t, bool n);
double get_diameter(marble m);
material get_look(marble m);
content get_material(marble m);
bool get_age(marble m);
void set_diameter(marble m, double d);
void set_look(marble m, content c);
void set_material(marble m, material t);
void set_age(marble m, bool n);
char *to_string(marble m);
-6- KIT107 Programming
Continued…
The types and variable required to implement members and the Club include the

Continued…
SECTION C — MEDIUM ANSWER QUESTIONS

A constructive — rather than destructive — implementation could comprise the following
functions:
void init_table(table *tp);
bool is_empty(table t);
table clone(table t);
table append(table t);
-10- KIT107 Programming
a. Implement the clone() function. You may write other functions to assist
your implementation.
[20 marks]
b. Using the clone() function, implement the append() function.
[10 marks]

如有需要,请加QQ:99515681 或邮箱:[email protected] 微信:codehelp

你可能感兴趣的:(KIT107)