SIT232 Programming Project 1
SIT232 Programming Project 1
Object-Oriented Development
Trimester 1, 2016
Assignment 1:
Programming Project 1
Work submitted late without documented approval of the Unit Chair will be penalised.
Assignments that are submitted after the submission date will be subject to a mark penalty equal
to 10% of the marks per day of the marks available for the piece of work, up to and including
three days after the published due date. Assignments submitted more than three days after the
published submission date will not be marked.
All work completed/submitted as part of this assessment task must be your own, individual
work. Any content drawn from other materials, including unit materials, must be clearly quoted
where appropriate, and/or clearly referenced. All students should review and be familiar with
the content provided by the University regarding how to reference other materials:
http://www.deakin.edu.au/students/study-support/referencing
http://www.deakin.edu.au/students/study-support/referencing/academic-integrity
ULO2 – Solve programming problems using object-oriented techniques and the C# programming
language.
You will be required to construct one or more object-oriented applications using the C#
programming language.
Question 1 (30 marks)
Objective: In this task you will be required to demonstrate your mastery / understanding of the
C# programming language. In the first few weeks of the unit we reviewed the basic syntax for
constructing an object-oriented application. As such, the instructions in the question below
should allow you to develop a working application straightforwardly. To complete this task you
will need to know how to develop logic for a program (knowledge from the pre-requisite unit),
and basic object-oriented concepts and the syntax of the C# programming language (from
studies in this unit).
Note: This task is a programming task worth 30 marks. If your submitted solution fails to
compile and/or run properly you have failed this task and will be penalized 50% of the
available marks for this question, i.e., you will lose 15 marks.
For this task we will be preparing an application to model the stock control and sales system
for a supermarket. Fundamentally, the products that supermarkets sell will be divided into
two categories:
Discrete products – these items are supplied to the supermarket and sold as individual
units, e.g., a packet of chips; and
Weighed products – these items are supplied to the supermarket in bulk and sold on
the basis of some measure such as $5 per kilogram which is weighed at the time of
purchase, e.g., fruit and vegetables
This question guides you to construct the bulk of the application, the next question will extend
this application. Sample output can be found at the end of this question sheet. Along with this
question, two C# program files have been provided that must be used in completing the
assignment:
Program.cs – this file contains the Main method which creates the initial data and
invokes the methods in the classes you define to establish stock levels and perform an
example purchase; and
Line.cs – this class coordinates the creation of lines of stock as well as representing
individual stock lines in the OO model.
No modifications are permitted to these files for this question. Any changes made to these
provided files for this question will result in a penalty of 5 marks per file.
Start by creating a new C# console application containing the above files. Below you will find
a specification of the features required for each class you need to define. For the majority of
these features, there are no problems to be solved and you only need to implement that
feature directly, thereby demonstrating your knowledge of the relevant OO concept. For
example, if you are required to add a feature to a class:
A private string attribute named ‘_BirthDate’
You would write in the class:
private string _BirthDate;
Class features that will likely require additional thought are indicated below using a symbol
for the bullet point.
1Note that text appearing in italics and underlined, e.g., example, refers to values stored in the object’s attributes.
The remaining parts of the text are just are reproduced as indicated.
SIT232 Object-Oriented Development Due: 5pm Wednesday May 3rd
Trimester 1, 2016: Programming Project 1 Page 2
Create a new class ‘Stock’ with the following features:
The class is abstract;
A private attribute to refer to a Line object named ‘_Line’;
A public read-only property encapsulating the above attribute;
A public custom constructor which accepts a single parameter line (Line) that
initialises the above attribute;
Three public abstract methods, as follows:
public abstract void AdjustStock(StockQuantity quantity);
public abstract bool Purchase(StockQuantity quantity, out Item item);
public abstract void Restock();
Build, test, and debug your program. Once complete, keep a copy to submit as your
Question 1 solution (Question 1 is marked separately to Question 2).
2 Note that this example is not particularly realistic, and there are other ways to do this, however the example
illustrates a technique you can use for the project requirements above.
SIT232 Object-Oriented Development Due: 5pm Wednesday May 3rd
Trimester 1, 2016: Programming Project 1 Page 5
Question 2 (20 marks)
Objective: In this task you will be required to demonstrate your mastery / understanding of
object-oriented relationships by extending your solution to the first task. This task focuses on
Weeks 4-6 (Relationships, Inheritance, and Polymorphism). Unlike the first task, you are not
provided with step-by-step instructions to complete this task. To complete this task you will need
to know how to create objects, establish relationships between them, and work with those
objects/relationships to build effective functionality, i.e., to demonstrate you can successfully
write code using an object-oriented programming language.
Note: This task is a programming task worth 20 marks. If your submitted solution fails to
compile and/or run properly you have failed this task and will be penalized 50% of the
available marks for this question, i.e., you will lose 10 marks.
For this task you are required to extend your solution to the first question to support a third
category of items: pre-packed items. Pre-packed items, such as meat products (consider
sausages or minced meat for instance), are stock lines that are purchased in bulk by the
supermarket and then packaged into discrete items before being placed on the shelf for a
customer to select for purchase.
Build, test, and debug your program. Once complete, submit your solution to this
question separately to your Question 1 solution (Question 1 is marked separately to
Question 2).
Question 1:
Question 2:
=====================
Stock Before Purchase
=====================
- 111111 - Original Corn Chips 150g Stock: 8 (20 in storage)
- 222222 - Special Supreme Pizza 500g Stock: 1 (50 in storage)
- 333333 - Golden Delicious Apples Stock: 2.000 kg (15.000 kg in storage)
- 444444 - Button Mushrooms Stock: 1.000 kg (5.000 kg in storage)
=======
Receipt
=======
5 Original Corn Chips 150g (0.75 kg)
1 Special Supreme Pizza 500g (0.5 kg)
1 Golden Delicious Apples 0.555 kg (0.555 kg)
1 Button Mushrooms 0.035 kg (0.035 kg)
1 Button Mushrooms 0.965 kg (0.965 kg)
====================
Stock After Purchase
====================
- 111111 - Original Corn Chips 150g Stock: 3 (20 in storage)
- 222222 - Special Supreme Pizza 500g Stock: 0 (50 in storage)
- 333333 - Golden Delicious Apples Stock: 1.445 kg (15.000 kg in storage)
- 444444 - Button Mushrooms Stock: 0.000 kg (5.000 kg in storage)