This assessment task provides an opportunity to perform some independent design and associated programming tasks involving multiple classes. The purpose of the task is to review some of the learning about object oriented programming from Programming 1, extend this a little and provide an opportunity during lab classes to gain feedback regarding your ability and progression in the course.
Learning Outcomes Assessed
K2: Discuss basic object oriented concepts
S1: develop object-oriented programs involving several interacting classes
a) write a small multi-class program with appropriate methods
b) write classes involving simple association relationships to other classes
c) properly apply the principles of encapsulation and information hiding
d) make correct use of object reference variables
e) perform testing and debugging using the debug mode in Eclipse
f) Code classes to ensure that objects will always have a valid state
g) Understand the significance of the ‘static’ modifier
h) Be able to design test cases to test methods of a class to ensure objects of that class behave according to its intention
I) Be able to arrange test cases into a test plan in order to thoroughly and adequately cover all key aspects of a class
j) Write a test driver to execute the test plan and
k) Be able to use Eclipse’s debugging tools to set breakpoints, inspect variables, and step through code to observe the behaviour of code to detect errors
Requirements to demonstrate:
a) Design interaction between classes so that objects of different classes can interact (i.e. send/receive messages)
b) Ensure that classes have an appropriate toString() method
c) Explain what object state means and how this can influence object behaviour
d) Describe how to ensure that an object’s state is always sensible
e) Code classes to ensure that objects will always have a valid state
f) Properly document classes, with method headers that are descriptive enough for other people to understand the code
g) Be able to design test cases to test methods of a class to ensure it behaves according to its intention
h) Be able to arrange test cases into a test plan in order to thoroughly and adequately cover all key aspects of a class
i) Write a test driver to execute the test plan and
j) Demonstrate use of Eclipse’s debugging tools to set breakpoints, inspect variables, and step through code to observe the behaviour of code to detect errors.
Discuss the objectives for this week and together design a simple system that involves at least two objects interacting. One of these objects must represent a food item of some kind (e.g. a cupcake or hamburger). The other object should represent a stall that the food item is sold from. Your system must involve at least two (2) associated objects that satisfy these rules:
a) The food item object must have some kind of dynamic status (for example you might represent the current status of the food item in terms of price, ingredients, or freshness). It must be possible to change the status of the food item using appropriate methods;
b) Your food item object must have a unique automatically generated ID that is created when you create each food item object;
c) The two objects are associated so one class has a reference attribute to identify the other object (for example a stall contains an array of food items – each stored as particular food item objects).
An example to inspire you follows:
A farmer’s market contains a variety of stalls. Each stall has a name, an owner and can sell a variety of food items according to its classification e.g. a hamburger stall might sell hamburgers, soft drink and chips, a cupcake stall might sell cupcakes and coffee. Every food item has detailed information stored about it such as the wholesale costs and retail costs. Food items can be hot or cold and come in small, medium or large.
Write a short description using words for your system that explains how the 2 objects interact with each other. Ensure you have described the interaction in terms of messages or actions between the objects. Show your tutor to verify your design before proceeding.
Discuss the methods required for each class design so that your objects are capable of the desired behaviour.
For each method, answer the following questions,
a) What does this method do (e.g. does it produce output or change the object state)?
b) When is this method valid (e.g. does the object have to be in a special state for this method to be performed)?
c) Plan a process to validate that the method is working as desired (e.g. create some specific test cases)
d) Write pseudo code to specify the logic and decision making required in this method
Draw a UML class diagram for each class (you may do this on paper or by using Enterprise Architect (available in the resources section on Moodle, see appendix))
If the previous step was completed using Enterprise Architect, you can generate code stubs for your two classes with set and get methods to be filled in, otherwise, you need to create the code yourself in a new Eclipse project
a) Take the code stubs generated in the previous step and create your own project in Eclipse.
b) Fill in code in the get/set methods
c) Create a toString() method for each class
d) Write the code for each method, based on pseudo code already written. Ensure you check that
e) objects are in the correct valid state for each method.
f) Write a simple test driver class to test your classes are working
g) Using the debugger mode in Eclipse, check that the states are being updated appropriately on your objects (you will be asked to demonstrate this use as part of exercise 2 of this document. This demonstration will take place in the laboratory in week 4)
h) Demonstrate to your tutor that your code works
As you conceptualise your system, it may assist you to consider a similar system involving students at a TAFE college enrolling into a Course. The enrolment phases include 5 possible status options for a student: applied, enrolled, completed, graduated, cancelled. When a student applies to the TAFE program, they are given a unique student number. The first student (ever) who is entered into the system is given the number 293142, subsequently, each student who applies is given the next available student number. Student numbers are always even numbers. As part of the TAFE program, students may be enrolled into a number of courses. Each course instance is allocated a teacher and has a list of enrolled students.
Example Class diagrams for 3 classes: Student, Course, TestDriver are provided on the next page.
Using examples from the code you wrote, (4 x 0.5 + 2 x 0.25 marks each = 2.5 marks)
a) Explain the difference between public and private;
b) Explain the principles of encapsulation and information hiding;
c) Describe and relate the terms: public interface, information hiding;
d) Explain the significance of the ‘static’ modifier;
e) Describe your chosen test cases;
f) Explain the results of your testing.
Demonstrate that you can use the debugger to your tutor by showing (3 marks)
use of Eclipse’s debugging tools to set breakpoints, inspect variables, and step through code to observe the behaviour of code to detect errors.
You will work on your coding in pairs, but must still submit your lab work including code and answers individually through Moodle in the assessment section. Some of your assessment may occur by interview during your lab class.
Feedback will be provided for this assessment task during your lab class.
Plagiarism is the presentation of the expressed thought or work of another person as though it is one's own without properly acknowledging that person. You must not allow other students to copy your work and must take care to safeguard against this happening. More information about the plagiarism policy and procedure for the university can be found at
Appendix: Enterprise Architect Help
To create a UML class diagram in enterprise architect, you need to follow these steps:
a) Create a new project
b) Create a new basic UML model, tick on ‘class’ model
c) Create a new diagram (project menu), tick on ‘class’ diagram
d) Drag classes and associations onto the diagram desktop from the toolbox on the left
To generate java source code from a UML diagram, use the ‘Tools’ menu and select the option ‘Source Code Engineering’.
project management assignment help, business management assignment help, business management assignment, management assignment help services, strategic management assignment help, management accounting assignment, management homework help, marketing management assignment help, human resource assignment help, human resource management assignment help, managerial accounting assignment help, management accounting assignment help, financial management assignment help, it management assignment help, project management homework help, hospitality management assignment help, hr management assignment help, operations management homework help, brand management assignment help, database management homework help