CSC72003 Assignment 1

1 CSC72003 Assignment 1 Weight: 20% of your final mark Due: 16 December 2019 10 pm (Hard Deadline) Specifications Your task is to complete various exercises in BlueJ, using the Java language, and to submit these via the MySCU link created for this purpose. Marking criteria includes: • Use of correct coding style, including the use of comments; • Accuracy of coding; • Use of suitable coding structures; • Correct submission and naming conventions of assessment items as required. Getting Help This assignment is to be completed individually. It is the opportunity to gain an understanding of the concepts of object oriented programming and coding syntax. It is important that you master these concepts yourself. You are permitted to work from the examples in the study guide or textbook but you must acknowledge assistance from other textbooks or classmates. In particular, you must not use online material or help from others, as this would prevent you from mastering these concepts. Who can you get help from? Use this diagram to determine from whom you may seek help with your program. Encouraged Attribution Required Ask tutor Not acceptable Lecturer Tutors Online Forums Relatives Students outside unit Hired coders Classmates Private Tutors Other 2 Assignment Q1 To be completed in week 1 Create a word document and call your document username-A1Q1.docx. For example, mine would be nfrancis10-A1Q1.docx Open the house project from chapter 1 of the book projects. Open the terminal window and record method calls. Create a picture with at least six (6) objects (circle, square, triangle, and person), recording all method calls. Take a screenshot of your picture and add it to the word document you created earlier. Now copy the list of method calls needed to create the picture to the word document after the screenshot. Add your name and student ID in the footer of the word document, as well as “CSC72003 Assignment 1 Q1”. Assignment Q2 To be completed in week 2 Create a new BlueJ project called username-A1Q2. For example, mine would be nfrancis10- A1Q2. Click on New Class and give the class a name of Computer. Make sure “Java” and “class” are selected. Write a description of your new Class in the top comments. Make sure you put in your name as the author and the date as the version you last worked on this exercise. Add 2 fields that are suitable for a computer. One field should have a type of int, the other should have a type of String. Add a third boolean field called isNew. Write a constructor for your Computer class that takes two (2) parameters – the first of type int, the second of type String. Set the initial values of the first 2 fields that you created using the parameters. Write accessor methods for all 3 of your fields Write mutator methods for all 3 of your fields 3 Write a method called printDetails, which prints out all the details of a Computer object. Please have a look at the ‘Printing’ section in the Topic 2 study guide to see how to do this. Take into account the isNew status. The printDetails method should have an if-else statement that prints a line saying that the computer is new, or the computer is not new. Assignment Q3 To be completed in week 3 Create a new BlueJ project called username-A1Q3. For example, mine would be nfrancis10- A1Q3. Create a class called Heater, that contains four fields, temperature, increment, max and min, all of whose type is double. Make sure you write a description of your new Class in the comments, with your name as author and date as the last date you worked on this exercise. Define a constructor that takes and sets the min, max and sets the temperature to 20.0, and increment to 1.0. Also define a constructor that takes no parameters. The temperature field should be set to the value of 20.0 in this constructor, increment to 1.0, and maximum and minimum to reasonable amounts. Define the mutators warmer and cooler, whose effect is to increase or decrease the value of temperature by the increment respectively. The mutator methods should not let the temperature be set to a value higher than max, or lower than min. Add a mutator method that sets the value of the increment. Add a check to make sure that the increment is not set higher than 3 or lower than 0. Define an accessor method to return the value of temperature. Test your work. Zip the project and include in your assessment files. Assignment Q4 To be completed in week 4 Create a new BlueJ project called your username-A1Q4. For example, mine would be nfrancis10-A1Q4. 4 Before you start to code, make sure to enable the “record method calls” in the BlueJ terminal. Create a class called LotsOfFruits, that has one ArrayList field called fruits, which holds a collection of Strings. Make sure you write a description of your new Class in the comments, with your name as author and give the version as the date you last worked on this exercise. Define a constructor that initialises the ArrayList. Note that you can add any other initialisations that you feel are relevant. Create methods to add elements, remove elements and get the number of elements in the collection. Make sure you add tests for errors and sensible error messages. Create a method called printFruits. This method should loop through the collection and print out the elements (each Integer on one line) as determined by the following rules; • If the fruit has a total letter less than 6, instead of printing the fruit name, it should print “ABRA”. • If the fruit starting letter begin with a vowel, instead of printing the fruit name, it should print “cadabra”. • If both conditions above are satisfied, it should print “Abracadabra”. • If none of the prior criteria are met, then the method should print the fruit name. For example, if the collection contained the Strings “akee”, “pear”, “strawberry”, then the printout would look like: Abracadabra ABRA strawberry Once you have finished your project, clear the terminal window in BlueJ and record the following. Add at least eleven (10) Fruits inside the ArrayList using the add method you wrote. You must have fruits that satisfy all of the printFruits conditions. Demonstrate removing an element using the remove method you wrote, and then find the number of elements using your method. Finally, run your printFruits method. Copy all your calls into a text file (.txt) and save it in your BlueJ project folder. 5 Assignment Q5 To be completed in week 5 Create a new BlueJ project called your username-A1Q5. For example, mine would be nfrancis10-A1Q5. Inside the project you will need to create two classes, which is PartA and PartB. Part A: Imagine you need to open a standard combination dial lock but don’t know the combination. Write a Java program in BlueJ with a method that prints all of the possible combinations, so you can print them on a piece of paper and check off each one as you try it. Assume the numbers on each dial range from zero to nine and three numbers in sequence are needed to open the lock. For example, the output would look like: 0-0-0 0-0-1 0-0-2 // lots more combinations 9-9-8 9-9-9 Part B: Suppose the lock isn’t a very good one and any number that’s no more than one away from the correct number in each digit will also work. Write another method that takes 3 parameters of type int that are the combination of the lock. The method will print out a minimal list of combinations you would need to try to guarantee opening the lock. For example, if the combination is 7-6-3 then 7-5-4, 6-6-2, 8-5-3 and other combinations will also open the lock. The first combination printed would be 6-5-2 and the last would be 8-7- 4. You will also need to make sure that no number in the combinations that are printed is less that zero and greater than nine as the numbers on each dial range from zero to nine. 6 Submission You should now have 4 BlueJ projects and 1 word document and a text file. You must zip the projects, the word document and the text file in into one zip file called usernameA1.zip. For example, mine would be nfrancis10A1.zip Submit this file via the Assignment 1 link on MySCU by the due date. Please leave enough time for it to upload, so do not submit at the last minute!

IMAT5101 OO Programming Assignment 1

IMAT5101 OO Programming Assignment 1 la 2019 Page 1 of 5 Faculty of Technology – Course work Specification 2019/20 Module name: Object Oriented Programming Module code: IMAT5101 Title of the Assignment: Assignment 1: Design and test a class This coursework item is: Summative This summative coursework will be marked anonymously No The learning outcomes that are assessed by this coursework are: 1. Be able to select appropriate API facilities in the design, implementation and testing of OO applications and applets. This coursework is: Individual This coursework constitutes 20% to the overall module mark. Date Set: Monday 23 rd October 2019 at 00:01. Date & Time Due: Monday 11th November 2019 at 23:59. Your marked coursework and feedback will be available to you on: If for any reason this is not forthcoming by the due date your module leader will let you know why and when it can be expected. The Associate Professor Student Experience (studentexperience-tech@dmu.ac.uk) should be informed of any issues relating to the return of marked coursework and feedback. Note that you should normally receive feedback on your coursework by no later than 20 University working days after the formal hand-in date, provided that you have met the submission deadline. By Friday 9th December 2019 When completed you are required to submit your coursework to: 1. Blackboard VLE through a submission portal. Late submission of coursework policy: Late submissions will be processed in accordance with current University regulations which state: “the time period during which a student may submit a piece of work late without authorisation and have the work capped at 40% [50% at PG level] if passed is 14 calendar days. Work submitted unauthorised more than 14 calendar days after the original submission date will receive a mark of 0%. These regulations apply to a student’s first attempt at coursework. Work submitted late without authorisation which constitutes reassessment of a previously failed piece of coursework will always receive a mark of 0%.” Academic Offences and Bad Academic Practices: These include plagiarism, cheating, collusion, copying work and reuse of your own work, poor referencing or the passing off of somebody else’s ideas as your own. If you are in any doubt about what constitutes an academic offence or bad academic practice you must check with your tutor. Further information and details of how DSU can support you, if needed, is available at: http://www.dmu.ac.uk/dmu-students/the-student-gateway/academic-support-office/academic-offences.aspx and http://www.dmu.ac.uk/dmu-students/the-student-gateway/academic-support-office/bad-academic-practice.aspx Tasks to be undertaken: See (following) attached document. Deliverables to be submitted for assessment: See (following) attached document. How the work will be marked: See (following) attached document. Module leader/tutor name: Chigozirim Justice Uzor Contact details: chigozirim.uzor@dmu.ac.uk IMAT5101 OO Programming Assignment 1 la 2019 Page 2 of 5 Assignment 1: Design and test a class This assignment counts 20% towards your module mark. The deadline for submitting your work via Blackboard is 23:59 Monday 11th November 2019. Assignment Objectives To demonstrate your ability and understanding in the following tasks: 1. To design and implement a simple class. 2. To write a test program to create instances of your class and demonstrate its behaviour. 3. To collect output from the test program runs, and comment on it. 4. To conform to Java coding conventions, including documentation style comments. Your Task You must create a general design for a class. Design, implement, test and document this class. You will need to make some assumptions and design decisions about the class. Ensure the class documentation makes the purpose and constraints of you class clear. You should strive to write your class so that it is potentially useful in other applications. Submission Submit four files via Blackboard. Replace with the name of your class: .java —source code of your class Test.java —test program for your class output.txt —output from the test(s) (plain text please) report.txt —short reflective report Add your own observations at the beginning or end of the output files. For example, were the test outcomes as expected? The report should be about 200-400 words with your reflections about your class, test program and results. You should comment on any assumptions that you made, and where improvements could be made to the design or implementation. Assessment Criteria – Grade indicators Pass (50 – 59): You have produced a class with appropriate fields, a constructor, and some modifier and accessor methods. There is a javadoc header describing the class. A test program creates an instance of the class and uses some methods. The code is suitably formatted, syntactically correct, and the test program executes, and output has been recorded. Merit (60 – 69): Criteria for a Pass have been met. In addition, all standard naming and coding conventions have been met. There has been consideration of class design, which is evidenced by javadoc comments, programmer comments, or the report. There is an appropriate level of documentation throughout the class. All constructors and methods have been used in the test program. The report gives an insight into the design and implementation decisions. Distinction (70+): Criteria for a Merit have been met. In addition, code style and documentation is to a professional standard. The class design is appropriate for the given scenario. Implementation is (almost) all correct and maintains the integrity of attributes where appropriate. The test program thoroughly exercises the methods and exposes any limitations, in addition to using an ArrayList. IMAT5101 OO Programming Assignment 1 la 2019 Page 3 of 5 Exercises Design, implement, and test ONE of the classes described below or specify your own. The class descriptions are deliberately vague in places. For your chosen class, you should use Javadoc comments to specify its purpose, properties and scope making appropriate assumptions where necessary. Additional note: To receive higher marks, in your test class you should aim to sensibly utilise an ArrayList, an overridden equals method, and the Scanner / PrintWriter for I/O. Classes marked with (60) or (80) are simpler than others and therefore can achieve at best those respective marks. You are strongly advised to attempt a (80) or (100) level class. Your tutor will indicate the level of complexity of any class you specify and you MUST get your tutors permission. You CANNOT use any class that has been discussed or provided to you during this module. Class Brief Description AddressName (60) An address has a house number, a street name, a town, county and postcode. This class should return the full address formatted appropriately. EmailAddress (60) An email address is made up of a real name, a user id and domain, e.g. Peter Jones . The class should return a correctly formatted email address. Clock (80) Models a 24 hour clock, which stores a time as hours and minutes. The time can be advanced. The client can retrieve the hours and minutes. FilmRental (80) A film DVD has a film title, duration, and category (e.g. U, PG, 15A). The DVD can be rented and returned. ScreenRobot (80) A robot has a (x, y) coordinate location. It can turn 90 degrees and move forward by some amount. It can go ‘home’ to its origin. CinemaBooking (80) A cinema booking can be for a number of adults and children. The child’s ticket price is half of the adult. The cost of the booking can be retrieved. TaxiJourney (100) A taxi journey has a start location and a destination. There is an estimated duration of journey and distance. The class should work out the fare based on a formula using the duration and distance (you can make up a suitable formula). HealthMonitor (100) A monitor can be used for a variety of purposes: heart beat, temperature, blood pressure. A monitor has a minimum and maximum value. If the current reading goes out of the expected range then an alarm is set. Stocklevel (100) A product in a shop has a particular quantity in stock. The is a minimum stock level, and when this is reached it indicates that the product needs to be reordered. Each item has a suggested reorder amount. Your own idea (?) . . . discuss with tutor first . . . Grade will be decided by your Tutor. IMAT5101 OO Programming Assignment 1 la 2019 Page 4 of 5 This may include taking an existing class such as Clock or ScreenRobot and agreeing some more advanced behaviour. Assessment indicator checklist These indicators will be used as a basis for the assessment mark and will form your feedback. (20%) Java conventions, and quality of documentation.  The class header documentation clearly describes the purpose of your class  Javadoc comments have been provided for each method and constructor  Javadoc param and return tags have been used appropriately  You have complied with standard Java conventions for identifier names and indentation (40%) Design and Implementation of the class.  Choose suitable fields, with appropriate data types  Declare a default constructor, which appropriately initialises fields  Declare a custom constructor, which appropriately initialises fields  Standard setter and getter methods have been provided as appropriate  A suitable toString method provides a textual representation of the current state  Other logical methods have been correctly specified and implemented  Internal validation within methods has been considered where applicable  Appropriate use of access modifiers (e.g. private, public) to encapsulate data (20%) Test program and output.  The test program uses each constructor  The test program calls each method at least once  The test program thoroughly exercises your class  The output file(s) show the outcome of test runs with your observations (20%) Correctness and Quality as evidenced by the overall submission.  Your class broadly meets the given specification  The code is syntactically and logically correct  Your class or test program shows technical flair/creativity  Your report gives an insight into your design and implementation decisions IMAT5101 OO Programming Assignment 1 la 2019 Page 5 of 5 Please note: Your overall mark may be capped at 60 or 80 depending on the level of complexity of the class you have attempted to design and implement.