Anda di halaman 1dari 7

Object Oriented Program Design 110 Assignment Specification Final Assignment Submission: 12.

00 midday, 3/6/2013 This assignment contains three sections: 1. The assignment specification. 2. Appendix A: The assignment cover page template. Assignments submitted without the completed cover sheet will not be marked. 3. Appendix B: A description of java code which allows you to get the current date and time from the system. 4. Appendix C: A proposed time schedule for successful assignment completion. Logistics This is not an assignment which can be put aside until a few days before it is due. You are required to perform assignment based tasks on a weekly basis. Your final mark will be directly coupled to: Your ability to ensure that progress on the assignment is made every week and that the weekly reading tasks are successfully completed. Your ability to communicate and to read and comprehend text based material. Your ability to demonstrate an understanding of how to design, implement and test an object oriented software application. Your ability to pro-actively seek assistance when required. Marking Strategy. The Pseudo code algorithm and Java implementation will be marked. The marks for your reading interviews will then be converted to a weighting in the range 0.0 to 1.0. This weighting will then be applied to the mark calculated from marking your pseudo code and Java code. The result is your assignment mark. You will be interviewed on the first eight chapters of the pdf file text book in the practicals occurring in the weeks indicated in the schedule contained in the unit outline. Please keep checking this timetable so that you are aware of when the reading interviews will occur. If you miss your practical in a week which has reading interviews then contact me immediately for an alternative. Note immediately means the second you realise you have missed your interview not three weeks later. Submission Requirements The assignment must be handed in in printed (not handwritten) form. Electronic copies of all assignment documents must be kept in your Curtin user account. The assignment cover sheet should follow the template provided in appendix A and all the information specified must be supplied and be correct. You must also sign the declaration on the cover sheet. Failure to conform to these requirements will result in your assignment not be accepted and marked. Each assignment submission should be made in hard copy form and should contain: A completed cover page (as specified in appendix A). A complete set of pseudo code and Java for the algorithms and code implementation for the software. Note the Java code must be compliant with the Dept of Computing Java coding standard (available from Blackboard) and must be fully documented. The Java code must be a valid implementation of your supplied pseudo code.

Java API Java comes with a fairly impressive library of classes which, for a developer, is incredibly useful. Unfortunately this makes an assignment in a unit such as OOPD110 very difficult because most tasks can be done via this library. For this reason you may not use any of the Java API classes other than: Those already used in the worksheets (e.g. System.out) Those mentioned in Appendix B. You are also not permitted to use arrays in your solution. You may also use the ConsoleInput class as you have been in your practicals. For the purposes of this assignment you may assume that when inputting a filename that the name consists of a collection of alphanumeric characters, followed by a period, followed by 1 or more alphanumeric characters. This means you can use the ConsoleInput.readWord method for this task. Software Description. A Caesar Cypher is one where each alphanumeric character in a body of text is shifted a fixed number of places to the left or right. The shift is circular so that if 'A' is shifted two to the left it becomes 'Y'. Similarly for lower case and digits (e.g. if '8' is shifted three to the right it becomes '1'. Characters which are not a letter or a digit are left untouched. You need to design in pseudo code and implement in Java an application which: Displays a menu allowing the user to choose from 1) encoding a file, 2) decoding a file and 3) quitting the program. The input should be an integer in the range 1 to 3. If encoding is chosen then the algorithm should prompt for an input file name and an output filename and then read each character from the input file, use the Caesar Cypher technique to encode it and then write it to the output file. Only alphanumeric characters should be shifted. See the section below for how to calculate the shift value. To encode the shift is a left shift. If decoding is chosen then the algorithm should prompt for an input file name and an output filename and then read each character from the input file, use the Caesar cypher process to decode it and then write it to the output file. Only alphanumeric characters should be shifted. See the section below for how to calculate the shift value. To decode the shift is a right shift. A time stamp should be printed on the first line of files containing encoded data. This should be of the format below: hour,minute,day,month,year There should not be any blank spaces on this line and each value should consist of the required number of digits. For example: 9,54,3,6,2013 represents a time stamp of 9.54am on June 3rd 2013. 15,5,25,10,2013 represents a time stamp of 3.05 pm on October 25th 2013. When decoding the file the time stamp should be read from the input file and displayed to

the user but output files containing decoded data should not contain a time stamp. You might find the Unix diff command rather useful because if the output of the command: diff fred barney is nothing then the two files contain exactly the same characters. Otherwise the output will be the lines in each file that are different. The shift value is calculated by counting the number of blank spaces in the text contained in the input file and taking the right hand two digits as the shift value (e.g. if there were 681 blank spaces then the shift value is 81). The shift is a circular shift so when you reach the end of the range of characters (e.g. 'A' to 'Z') then you wrap around to the other end and keep counting. For example if the shift value is 81 and the character is an uppercase letter then your algorithm would wrap around three times and then move 3 places so if the upper case letter was 'M' and it was a right shift then the new character would be 'P'. OOPD-110 does not teach file access in Java so a small Java library has been provided for your use ( which can be downloaded from Blackboard). All file access MUST be done via the Java code in this file. You are not permitted to make use of any of the standard Java API for file access. The file has been documented and all students should print out the file and go through and understand the function of each method in the file BEFORE they attempt to make use of it in their assignment. To test your knowledge you should develop some test programs which do things like copying the file out to the screen or copy from one file to another (no cyphers involved). You must have the following classes in your design. You should have other classes as well but these ones must be present and must fulfill the specifications below: Class TextFile: used for file access and provided for you to use. Take a copy of this code from blackboard. There is no need to provide pseudo code for this class. Class DateClass: used for keeping track of a date. This is the example class provided on Blackboard. There is no need to provide pseudo code for this class. Class Time: used for keeping track of hours and minutes expressed in the 24 hour clock. You must design this class in pseudo code and implement it in Java. Class CypherFile: This class must inherit from the class TextFile. Its sub class functionality must provide a means of: Determining the shift value for the input file. Left shifting a character using the shift value. Right shifting a character using the shift value. You must design this class in pseudo code and implement it in Java. Class TimeStamp: used for keeping track of the current date and time. You must design this class in pseudo code and implement it in Java. You must make good use of two other classes when designing this class. Object Orientation Issues In addition to the previously mentioned class, others will be required. Students should give

careful thought to the best arrangement of classes for the application. Marks will be allocated for your choice of classes as well as for the overall functionality of your algorithm and Java implementation.

Appendix A

Object Orientated Program Design 110 Assignment Cover Sheet Semester One 2013
Student Number: Family Name: Other Names: I declare that: 1. I am aware that use of work done by others without declaring where the work came from IS plagiarism. 2. This assignment is all my own work (other than the code supplied by the unit controller). 3. Curtin University has a Student Misconduct Policy and, should I use the work of another in my assignment then I will be in breach of this policy. Student Name (Print): Student Signature: Date:

Appendix B

Java Code for Getting the Current Date and Time

Consider the Java code below. This code successfully retrieves the current date and time. You must use exactly the same API library calls in your assignment. The date and time MUST be stored in appropriate objects (e.g. date in a dateClass object. Similarly for time. import java.util.Calendar; public class WhatTime { public static void main( String [] args) { int day, month, monthField, year, hours, minutes; Calendar cal; cal = Calendar.getInstance(); day = cal.get(Calendar.DAY_OF_MONTH); monthField = cal.get(Calendar.MONTH); year = cal.get(Calendar.YEAR); month = calcMonth( monthField); hours = cal.get(Calendar.HOUR_OF_DAY); minutes = cal.get(Calendar.MINUTE); } public static int calcMonth( int monthField) { int month = 0; switch( monthField) { case Calendar.JANUARY: month = 1; case Calendar.FEBRUARY: month = 2; case Calendar.MARCH: month = 3; case Calendar.APRIL: month = 4; case Calendar.MAY: month = 5; case Calendar.JUNE: month = 6; case Calendar.JULY: month = 7; case Calendar.AUGUST: month = 8; case Calendar.SEPTEMBER: month = 9; case Calendar.OCTOBER: month = 10; case Calendar.NOVEMBER: month = 11; case Calendar.DECEMBER: month = 12; } return month; } }

break; break; break; break; break; break; break; break; break; break; break; break;

Appendix C

Development Schedule
Often students make the mistake of waiting until everything required for an assignment has been covered before they commence work on their assignment. This is not possible in the case of this assignment. Firstly the reading part of the assignment occurs throughout the semester. In terms of the programming task I suggest the following schedule: By week 3 have an understanding of what the assignment is asking you to do. You will not know how to do it but be familiar with the specification. By week four, test the code provided in Appendix B and make sure you can get it to work on the computer you intend to do your assignment on. By week5, design in pseudo code and implement in Java a program which inputs a character and a shift value and outputs the character shifted to the left and the right by the input value. By week 6 modify the algorithm you wrote for week 5 so that any character can be input but it is only shifted if the character is alphanumeric. By week 7. Write an application that uses and copies the contents of one file, character by character to another file. Also design an algorithm that will display a three option menu, input an option, do the option and repeat this process until the option is quit. By week 8 to 10. Start designing the required classes in pseudo code. Begin by getting your copy of dateClass to compile. Then start with the simple classes and work your way towards the sub class that is required. By week 12 you have most of the bits and pieces done to complete the assignment so now finish it and test it.