Ict_167 - Lecture Notes
Page 1: Lab Practice Week 8 Overview
Submission Guidelines
Show working versions of answers to all questions.
Submission of answers to Exercises 1 and 2 is required.
External students must arrange submission with their tutor.
Weekly submission of Lab Practice work is necessary; avoid end-of-term catch-up as workload increases.
Late submissions without an acceptable reason will receive zero marks for the week.
Recommended Practices
Attempt all exercises each week to broaden understanding which may aid in assignments.
Complete all programming tasks using an Integrated Development Environment (IDE).
Internal documentation in code is crucial. Refer to chapter 2.4 in the textbook for guidance.
Concepts to Explain with Programs Developed
Sorting Algorithm: Understanding different sorting methods.
Inheritance: Classes and subclasses in object-oriented programming.
Overriding Method: Re-defining methods in subclass for specific functionalities.
Polymorphism: Multiple forms of methods that might be executed based on specific conditions.
Dynamic Binding: Runtime method resolution depending on the object being referenced.
Exercise Details for Insertion Sort
Extend Exercise 1 from Lab Practice 5.
Write a method to sort an integer array in ascending order using the Insertion Sort algorithm.
Call this sorting method after displaying the original array and other statistics.
Display the sorted array’s contents similarly to previous approaches.
Page 2: Patient and Playgroup Class Development
Exercise Instructions
Enhance the class Baby from Exercise 3 in Lab Practice 5:
Add the method
BabySound
: Print "Baby Sound is Neutral" to indicate a normal state.Define the subclass
Patient
: Used for storing clinic records.Derive
Patient
fromBaby
including:Patient name and age (inherited from
Baby
)Identification number (integer type).
Include necessary constructors, accessor methods, and an equality method for the
Patient
class.Equality: Two patients are equal if their identification numbers match.
Override
BabySound
: Print "Baby Sound is Sick" for sick babies.
Define another subclass
Playgroup
: Used for playgroup member records.Derive
Playgroup
fromBaby
with:Baby name and age (inherited).
Include necessary constructors, accessor methods, and an equality method.
Equality: Two playgroup members are considered equal if their names and ages match.
Override
BabySound
: Print "Baby Sound is Happy" to show happiness.
Client Program Requirements
Create an array of type Baby to store information for up to 4 babies.
Procedure to enter details:
For the first item (Patient object), input name, age, and ID.
For the second item (Baby object), input name and age.
For the third item (Playgroup object), input name and age.
For the fourth item (Baby object), input name and age.
Display details of each baby and respective sounds.
Output all information stored, including baby sounds, to a file named Baby.txt.
Polymorphism Explanation
Discuss polymorphism in context of the above exercises, referencing relevant textbook content.
Include testing strategy and sample test results similar to assignment formats.