ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 1 of 15
Major Assignment
Semester 1, 2017
Learning Objectives:
The learning objectives for this major assignment are:
K1. Explain the principles of inheritance, composition and their consequences
K2. Discuss basic object oriented concepts
K3. Explain the principles of event-driven programming
S1. develop object-oriented programs involving several interacting classes
S2. incorporate pre-written classes, including those from the SDK, into software solutions
S3. develop object oriented programs which involve both object oriented and event driven aspects
A1. design, develop, test and debug programs from supplied program specifications
Purpose
By completing this assignment, you will develop your understanding of and apply object-oriented programming techniques, in particular those relating to inheritance and polymorphism. You will develop skills and experience in the use of the Java Collections API classes and I/O classes. You will demonstrate your ability to successfully design and develop a working event-driven system.
You will develop a multi-class program to meet functional specifications applying design principles, and making use of the ArrayList and Map abstract data types.
You are encouraged to partner with another student and engage in paired programming to complete this assignment.
This major assignment will be submitted in 3 stages. Each stage will build on the previous stage. You will also be asked to demonstrate or describe your code to highlight particular concepts you have implemented. This demonstration/reflection will be individually assessed.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 2 of 15
Assignment Overview:
This assignment requires you to complete various tasks involving classes you write with your partner. You may also use classes that you find in the Java SDK. The system that you will create is a Restaurant Menu Management System (RMMS). The RMMS is a tool used by a restaurant or chain of restaurants that manages multiple menus. The menus may be used potentially at different venues, for different purposes (e.g. take away) and/or for different opening times. Each Menu has a name and is associated with a particular venue and session time. For each Restaurant menu, there are a number of available meals available for ordering by patrons or guests. It is possible that menus are made available for different purposes including take away or eating in the restaurant. This IT system, RMMS, will enable the head chef or front of house manager to customise and save menus to the system as well as view the stored list of menus. It will be possible to inspect details for each menu. The details will include specifics of the menu as well as specific details regarding discounts that may apply to certain meals (eg. Meals displayed on the ‘Specials board’ in the restaurant). Menus will be saved separately as specific individual menus (e.g. take away menu, lunch menu, special function menu, dinner menu). It will also be possible to categorise particular meals on each menu. The menu item categorisation will determine the way that prices are calculated for display on the menu. Each menu item will have a basic price associated with it, when the price for display on the menu is calculated, this calculation may involve increasing the price with surcharges (e.g. some special meals might have a surcharge due to the difficulty in sourcing their ingredients locally); or decreasing the price due to a special discount. You will be required to develop your application using Java in the Eclipse environment. You will create a GUI using the java.swing library package.
You will need to zip your project up when you are finished each stage and submit it as a single zip file to Moodle by the due date. You will also need to submit a report. The report will require some written and diagrammatic information describing your system. Please write clearly and IN YOUR OWN WORDS (plagiarism is NOT acceptable – refer to Course Description).
It is expected that each student pair will creatively design and author a unique system based on individual design choices that fit with the requirements listed in each task. Before you begin, read over the entire assignment and understand all the tasks. Acknowledge authors for all code that you submit using in code comments.
All code must conform to stylistic standards including proper commenting, appropriate choice of identifier names (including case), proper indenting and other readability issues. Otherwise, marks will be deducted. Consult http://www.oracle.com/technetwork/java/codeconventions-150003.pdf
Stage One is due in week 7. Stage Two is due in week 9. Stage Three is due in week 11. In week 12, you will be interviewed by your tutor in your lab class. You will be asked questions about your code.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 3 of 15
Stage 1a Designing and Documenting your system Due date: Week 7 Create a document named: surnameStudentIDAssign1.doc . In your document, you must include the following section headings:
• Authors, • System Overview, • Class Diagram, • Testing.
System Overview
In the System Overview section you are to write 100-200 words describing your system and how it could be used in an imaginary/real world scenario. You will need to review this after completing all tasks and ensure that your overview explains your entire system. State any assumptions you are making in your system. It is expected that you will create a system that can accommodate managing a number of menus (e.g. lunch take away, or special function menu, or a la carte evening menu served in the restaurant/s). For each menu, there should be an associated kitchen name or venue name and a number of meals available each associated with a unique item number on the menu on which it appears. Each menu item has related information such as price($) and the menu item name. You may add further attributes such as description if you wish. You may also choose additional attributes for your menu such as venue or description.
The price that appears on the menu for a menu item may be different from the price entered into the system. The price displayed on the menu depends on the type of menu item. There should be a number of possible types of menu items incorporated into your system. Example menu item types are as follows:
1. A standard menu item will have the price calculated based exactly on the price entered into the system. 2. A premium menu item can be created with a mechanism to indicate that it is to have a surcharge added to the price. The surcharge will increase the price of the meal based on a constant percentage mark up value specified by the chef; 3. It is possible to create a discount menu item meal to apply a discount to the given price;
The RMMS system will have at least 3 different menu item types (e.g. standard menu item, premium seasonal menu item and discount menu item). You may choose a name for these types and what the distinguishing features of each type of menu are. It is suggested (at a minimum) that each menu type will have a different process for calculating the published price on the menu.
Each menu created is expected to have at least 5 associated menu items. The total number of menu items is limited to a maximum of 200 and your system should allow for multiple pages of menu items. Your system will be able to add menu items to the menu after it has been created. The menu details will include a name and description as well as details naming a data file that will be used to preload menu items. A MenuItem is a generalised class representing a generic menu item, each actual menu item created will be instantiated as one of a specialised type of menu item that inherits from menuItem.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 4 of 15
Class Diagram
In this section, you are to provide a class diagram for every user authored class you anticipate in your first version of the system. The first version will include a text based menu driven system with classes that will be used to create objects to represent 3 different menus, as well as different menu items of various types that belong to each menu. You are expected to use inheritance so that you have an abstract menu item class and specialisation classes for different types of menu item.
Testing
As you develop your classes and methods, you will write testing code to verify that your code is working correctly. In this section, you will describe your initial chosen test data and explain how that data will help you test your code. Make sure that you choose a variety of test cases to ensure you can be satisfied that your code is working. Describe your test cases and include screen shots of your testing results (so far) in this section.
Stage 1b - Task 2 Creating classes for menus and menu items using associations and inheritance. Due date: Week 7 Create a new project in Eclipse called Assignment 1.
Within this project create a package called MenuManagementSystem.
1. Author six classes within your newly created package: General classes to create first are Menu, MenuItem and your RestaurantDriver class. In addition to these, you are to create at least THREE classes representing possible types of menu items that are specializations on the general abstract class: MenuItem. All MenuItems have (at least) the following attributes: itemName (String), itemPrice(double). When designing your specialisation classes, you may choose further additional attributes particular to each specific menu type. Each menu type will have a different getPrice() method that will override the getPrice method in the abstract class MenuItem and calculate the price to display on the menu based on the rules for each type. 2. You must provide at least 2 constructors for each particular specialised menu type class: a. A default constructor which assigns each instance variable a default value. The String variables (e.g. itemName) should be initialised to “unknown”, the price should be initialised to a minimum default price and any object fields initialised to null. b. A constructor with parameters which assign values to each instance variable. Note that the values to initialise the values and objects should be passed in using arguments when the constructor is called. 3. Create a seventh class, MenuItemDatabase that you will use to manage a group of menu items. This class will be associated with the menu class. The menu will have an attribute that is referencing an object based on this class. The MenuItemDatabase class will contain an ArrayList of
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 5 of 15
MenuItems as well as an appropriate method named insert that could be used to add a particular MenuItem into to the list of MenuItems. The insert method should take 2 parameters: an integer value representing the menu item number (corresponding to the number on the menu) and a menu item object. Also author a method named retrieve that will get the menu item in a given index position from the Arraylist. You can assume initially that the index position corresponds to the item number on the menu. 4. Author get and set methods for your classes for instance variables where appropriate. 5. Write a toString() method in each class that will return a String containing all the relevant data for each of your objects. 6. In each of your specialised menu item classes, create the getPrice method to perform an appropriate price calculation based on the data in the object. 7. Create a TestDriver class. In this class, provide a main method containing code to implement your test plan to test all constructors and methods including your toString () method, for each class you have written. Run your tests and make sure your class is behaving correctly. 8. Write further code in your test driver so that you can create a menu for a particular kitchen/venue/time and add items to that menu. This should be menu driven so that you can manually input some data. You may also like to hardcode some test cases. 9. In your documentation, outline your test plan (For example, outline what objects you created in order to demonstrate that your classes written so far are working correctly). 10. Explain how you have tested your code and the results of your testing. Include screen shots in your documentation demonstrating the output when you tested your code. 11. Document all methods in your code using comments. You may be creative with the individual class attributes you associate with your objects and methods you create. If you have any difficulty with ideas, discuss this with your tutor.
After submission of stage 1, an example UML solution will be discussed by your tutor to help you progress to stage 2 and stage 3.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 6 of 15
Stage 2 Convert your MenuItem to become an abstract class, Populating your Menu from an input file, producing output to a report text file, creating a customer order, using abstract data types (Map). Due Week 9
1. Create an input file MyHotel.txt containing at least 10 different menu items (ensure you have at least one of each different menu type). The data for each will include the Name of the kitchen restaurant and then a number of items. The category for each item should be identified.
Your file may look something like this: (it doesn’t have to look exactly like this – the format is up to you). In this example, for the venue: “My Hotel”, there are 4 menu item types: Premium, Standard, Discount and Special.
My Hotel
Premium 1 Spring Roll 1.00 Premium 2 Homemade Dim Sim 1.20 Standard 3 Fried Won Tons 5.00 Standard 4 BBQ pork with plum sauce 5.50 Discount 5 Chinese crispy sausage 5.00 Discount 6 Prawn cocktail 8.00 Premium 7 Garlic prawns 9.00 Special 8 Honey prawns 9.00 Standard 9 Fried noodles 2.00 Special 10 Prawn crackers 2.50 Special 11 Chicken scrambled egg soup 4.00 END
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 7 of 15
2. In your submission report describe the actual format of data in your data.txt file. Name the fields of data that will be in the file and the order in which they will be found. (e.g. Venue or Menu name will be first and will be a string on one line, then a number of menu items will follow ….etc.) 3. Modify your MenuItem class so that it is an abstract class. Change your getPrice and SetPrice methods to be abstract methods in MenuItem so that they must be overridden and provided in each inherited special menu item class. 4. Write a method on your menu class to read the menu and menu items information from the file, and create a new restaurant menu. This includes populating the menu with menu items based on data from the file. You will need to create the correct menu item type based on information in the file. 5. Write a toString() method that will generate an output string detailing the menu. Use polymorphism where possible. 6. Extend your system so that it will allow a customer to read a menu displayed and then place an order based on a particular menu. The order can contain 1 or more menu items that have been selected. If the order is a take away, you need to add a further delivery charge to the order. 7. Add further code to your driver class and write a test method which tests your system using a text based menu system. Test using a scenario involving displaying a menu and asking a customer to place an order. In your report document, describe the testing scenario and the expected behaviour of your system. Provide screen shots of your system testing in your final report. Write a method to appropriately populate your menu with details read from a file. Ensure you have comments to describe each of your new classes in your code. 8. Add a method to output a menu saved to a file. This output report must for each menu save details particular to the menu, including the menu items and their data including the base price (which may be different from the displayed price). 9. Test your classes to check they are working correctly. Document your testing process – describe your test data and the outcome of your testing. Include screen shots in your report document illustrating your testing process and the outcome of your testing. 10. Change your menu item management class that manages a collection of menu items. In this class, you will replace the ArrayList with a Map data type in which you can store a number of menus. You can assume each Menu Item number is unique. The map data type that enables you to look up and easily retrieve details for a menu item given its item number off the printed menu. Use the item number as the key. 11. Further test your system to ensure it is working, document your testing process. 12. Update your UML class diagram so that it is consistent with your code. (You may use Enterprise architect to import your code and generate the class diagram).
After you have submitted stage 2, a partial code solution for stage 2 will be provided for viewing at the discretion of your tutor at individual consultation appointments.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 8 of 15
Stage 3 creating a GUI Interface Due Week 11
In this stage, you will create a GUI interface for your system. This will replace your text based menu in the TestDriver created in stage 2. There is example code on moodle that demonstrates how to create a GUI. You are strongly encouraged to refer to those examples.
GUI Design
Draw a schematic sketch of your GUI design. On your diagram, highlight where you intend each panel to be and the contents of each panel (e.g. buttons, lists, radio buttons, labels). Where you have content to be displayed based on an object in your code, note this on your diagram. Also, indicate the events you expect your GUI to respond to and what happens following each event. For example, “when the button < X> is pressed, this event will trigger a call to method which will perform a calculation using the values in the selected list and display the result in the text field in the center panel. “
Figure 1. Sample GUI interface when 1 menu has been selected to inspect
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 9 of 15
Design and coding of the GUI using the swing library
Create a new class that will manage your GUI System. This class will take one parameter when constructed, a reference to a Menu object. So, if you invoke your GUISystem class twice (with two different menus), you will create two separate windows – one for each menu. Figure 1 shows a sample GUI where one menu has been loaded. Figure 2 gives an example where 2 different menus were loaded.
Figure 2. Sample GUI interface when 2 menus have been selected to inspect
The examples above are indicative of the minimal requirements for your GUI window for each Menu. You will also have the initial startup GUI window where you provide a list of menus available to view. You must be able to select a menu to display and then when you click on the button to open that menu(s), each menu will appear in a new separate window. It is expected that no submissions will be identical, so ensure that your GUI has some unique elements to it. Be creative! It is expected that each student pair will creatively design and author a unique system based on individual choices that fit with the requirements. You must satisfy the following requirements for full marks on this task: • Display in a startup GUI window the list of Menus available to inspect, select one or more (using a checklist) to then view to edit. For each menu selected, create a new GUI window for that menu.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 10 of 15
• Create and use at least 2 buttons on the start up GUI, to open a menu and to exit the system • Include a button that ‘does’ something based on the menu (e.g. calculate and display the total price for the order) • Use check boxes to allow a user to select the menu items to create a customer order. These should be populated by a vector list and should be consistent with the menu items that are stored for that menu. • Display in a scrollable output text box the order details based on user selection. (The order details do not need to be saved as this restaurant will not keep records of each individual customer order). • In addition, your code must be well designed into methods applying the principles of coupling and cohesion. You must deal with exceptions appropriately.
Figure 3. Sample GUI following user selection of menu items and displaying order details. My Hotel Order shows output following button click Display Totals. Hotel City shows output following selection of 2 items.
Note: your GUI does not need to create /edit or save your menus. Those administrative functions from stage 2 could be done using the text based menu by the chef. The GUI is primarily for the staff waiters and staff at the counter taking orders.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 11 of 15
Additional Task (ITECH 6100 students only) Using examples from your own assignment code, write half a page (at least 250 words) explaining the difference between an abstract class and when/how it is used, compared with extending a non-abstract class. Allocated Marks: See Course Description You will be marked on the design and quality of your code, your documentation and also your ability to individually answer questions based on this code in an interview. Due Date: See Course Description Please refer to the Course Description for information relating to late assignments and special consideration. Plagiarism: Please refer to the Course Description for information regarding Plagiarism. Assignment Submission: Assignments must be submitted by the due date and your assignment should be completed according to the General Guidelines for Presentation of Academic Work (http://www.ballarat.edu.au/aasp/student/learning_support/generalguide/) and programming standards (http://www.oracle.com/technetwork/java/codeconventions-150003.pdf).
The following criteria will be used when marking of your assignment: • successful compilation • successful completion of the required tasks • ability to answer questions about your code and concepts demonstrated in your code • adherence to the guidelines provided • quality of code that adheres to the programming standards for the Course including: • comments and documentation • code layout • meaningful variable names You are required to provide the following documentation: • a statement of what has been completed and acknowledgement of the names of all people (including other students and people outside of the university) who have assisted you and details on what parts of the assignment that they have assisted you with • a table of contents and page numbers • tasks requiring written responses • class diagrams • list of references (including websites, the text book and any other resources) used (APA style); please clearly specify if none have been used.
For each stage submission, submit the code project source code and your documentation in one zip file to Moodle.
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 12 of 15
Student ID: _______________________ Student Name: ______________________________________
Stage 1a - documentation 2
System Overview Description
Class Diagrams Test plan
0.5
0.75
0.75
Stage 1b - coding 4
Demonstrated appropriate use of abstract classes and specialization classes with appropriate use of overriding of methods for getPrice()
Appropriate constructors, private variables where appropriate
Appropriate use of parameters in method design
Appropriate use of an ArrayList collection class
Evidence of testing
1
0.5
0.5
1
1
Comments
Total Marks
/6
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 13 of 15
Student ID: _______________________ Student Name: ______________________________________
Stage 2 9 Demonstrated reading from and writing to text file successfully 2
Documentation of file format in report, including example data from test data.txt file
Use of abstract class and abstract methods with overridden methods in inherited classes.
0.5
0.5
Additional functionality to calculate total price for a customer order including delivery
1
Appropriate use of map abstract data type for storing and retrieving a number of menu items
1
Demonstrated use of polymorphism where appropriate 1
Menu driven system driver 1.0
Testing 1.5
Updated UML diagram 0.5
Comments
Total Marks
/9
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 14 of 15
Student ID: _______________________ Student Name: ______________________________________
Stage 3 9 (+2)
GUI design sketch and description 0.5
GUI works with correct functionality – with start up GUI and new windows for each menu
Buttons implemented using appropriate listeners on all windows
Text fields used for output of order details
Check boxes populated based on a vector created from the menu items on the menu
Hotel Name displayed in window
Scrollable panel displays all menu items
Well designed code using methods, parameters and variables appropriately
Bonus marks awarded for extra functionality
1
1
1.5
1
0.5
1.5
2
2
Comments:
Total Marks /9
ITECH 2100 / 6100 Programming 2 School of Science, Information Technology and Engineering
CRICOS Provider No. 00103D ITECH 2100/6100 Major Assignment 2017 Sem 1 Page 15 of 15
Student ID: _______________________ Student Name: ______________________________________
Final Interview (individual mark) 6 Your tutor will ask you to demonstrate and explain features in your code as well as provide examples showing concepts such as use of information hiding, abstract data types, data management façade class, try and catch clauses, inheritance and polymorphism. ITECH6100 students will be asked to also give an oral summary of their additional written task to contribute to this mark.
Additional Task (ITECH6100 students only) Appropriate referencing
Use of appropriate examples from code authored by student in this assignment
Clear and well expressed explanation
Comments:
Total Marks /6