Lab Exercise 4: Inheritance and Polymorphism CS 2334

Similar documents
Lab Exercise 6: Abstract Classes and Interfaces CS 2334

CMPSCI 187 / Spring 2015 Sorting Kata

CMPSCI 187 / Spring 2015 Hangman

CMPSCI 187 / Spring 2015 Hanoi

ASSIGNMENT 5 Objects, Files, and More Garage Management

Assignment Manager. Change Edit Mode to On if it is not already by clicking on the option at the top right of the window.

CSSE2002/7023 The University of Queensland

Tips from the experts: How to waste a lot of time on this assignment

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

ASSIGNMENT 5 Objects, Files, and a Music Player

CSE115 Lab 9 Fall 2016

CSE100 Principles of Programming with C++

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

CS 2604 Minor Project 1 DRAFT Fall 2000

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September

3. When you process a largest recent earthquake query, you should print out:

Assignment 3 ITCS-6010/8010: Cloud Computing for Data Analysis

Our second exam is Monday, April 3. Note that it will not be possible to get all the homework submissions graded before the exam.

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.

PA3: Violet's Vending Venture (Version 3.0)

CS 051 Homework Laboratory #2

Project #3. Computer Science 2334 Fall Create a Graphical User Interface and import/export software for a Hurricane Database.

Part 1: Group Brainstorm (NO computers during this time) Part 2: Submit Individual Brainstorm (You can now use a computer)

There are several files including the start of a unit test and the method stubs in MindNumber.java. Here is a preview of what you will do:

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Assessment details for All students Assessment item 1

Submitting Assignments

Web-CAT Guidelines. 1. Logging into Web-CAT

CSCI 1301: Introduction to Computing and Programming Spring 2018 Project 3: Hangman 2.0 (A Word Guessing Game)

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

CS 142 Style Guide Grading and Details

CS 2604 Minor Project 1 Summer 2000

CS 140 Programming with Objects

San José State University Department of Computer Science CS151, Object Oriented Design, Section 04, Fall, 2016 (42968)

Homework Assignment #3

Tips from the experts: How to waste a lot of time on this assignment

Data Structures and Algorithms

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

Lab 1 Implementing a Simon Says Game

CMPSCI 187 / Spring 2015 Postfix Expression Evaluator

Project 3: Implementing a List Map

A4: HTML Validator/Basic DOM Operation

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees

Assignment Tutorial.

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

Introduction to Programming System Design CSCI 455x (4 Units)

Tips from the experts: How to waste a lot of time on this assignment

COMP 412, Fall 2018 Lab 1: A Front End for ILOC

Spring 2018 El Camino College E. Ambrosio. Course Syllabus

CS 111: Programming Fundamentals II

CSCI 200 Lab 2 Inheritance, Polymorphism & Data Streams

ECE2049: Embedded Systems in Engineering Design Lab Exercise #3 C Term Making a Time and Temperature Display

CSE Lab 7 Assignment

Project 6: Assembler

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Instructor Feedback Location and Printing. Locating Instructor Feedback When Available within Canvas

Com S 227 Assignment Submission HOWTO

WEB-CAT. Exploring Trends and Student Behaviors from Data Collected on an Automated Grading and Testing System

Programming Assignment HW4: CPU Scheduling v03/17/19 6 PM Deadline March 28th, 2019, 8 PM. Late deadline with penalty March 29th, 2019, 8 PM

gcc o driver std=c99 -Wall driver.c bigmesa.c

CSCI 200 Lab 1 Implementing and Testing Simple ADTs in Java

Decision Logic: if, if else, switch, Boolean conditions and variables

Creating a Turnitin submission

ASSIGNMENT TOOL TRAINING

Cmpt 135 Assignment 2: Solutions and Marking Rubric Feb 22 nd 2016 Due: Mar 4th 11:59pm

CS 1044 Program 6 Summer I dimension ??????

/ tel: / tel:

Viewing Grades and Feedback in Blackboard

MATLAB Demo. Preliminaries and Getting Started with Matlab

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

CpSc 1111 Lab 5 Formatting and Flow Control

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

For storage efficiency, longitude and latitude values are often represented in DMS format. For McBryde Hall:

CS 2110 Summer 2011: Assignment 2 Boggle

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

TURNING IN ASSIGNMENTS

Project #1 Computer Science 2334 Fall 2008

02/03/15. Compile, execute, debugging THE ECLIPSE PLATFORM. Blanks'distribu.on' Ques+ons'with'no'answer' 10" 9" 8" No."of"students"vs."no.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

SCORELATOR Instructor Guide Logging In: Getting into SCORELATOR is fast and easy Forgot your password?

CpSc 1111 Lab 9 2-D Arrays

Our second exam is Thursday, November 10. Note that it will not be possible to get all the homework submissions graded before the exam.

Be sure check the official clarification thread for corrections or updates to this document or to the distributed code.

EECE.2160: ECE Application Programming Spring 2019

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

This is a combination of a programming assignment and ungraded exercises

Central Washington University Department of Computer Science Course Syllabus

Assignment 3: Due Thursday Feb 26 at 11pm

CMSC 132: Object-Oriented Programming II. Administrivia

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

CS 152 Computer Programming Fundamentals Lab 7: Book and Author Objects

COS 126 Midterm 2 Programming Exam Fall 2012

Turnitin Feedback Studio. Office of Distance Education

Data Structures and OO Development II

Transcription:

Lab Exercise 4: Inheritance and Polymorphism CS 2334 September 14, 2017 Introduction With this lab, we consider relationships between objects. Think about the records that we keep for every item used to compute your grade in this course. Each of these Assignments has a name, a date, a score, a total point count and a weight. We will use class inheritance in this lab to capture the fact that different types of Assignments have some properties in common, but differ in other properties. For example, a Lab might have a specification document, and a Project might have both a specification and a data file. In addition, we will use class aggregation to represent a list of Assignments. Learning Objectives By the end of this laboratory exercise, you should be able to: 1. Read and understand UML diagrams involving class inheritance 2. Implement classes from a given specification 3. Create inheritance relationships 4. Understand the difference between is-a and has-a relationships 5. Develop testing procedures for your own code 1

Proper Academic Conduct This lab is to be done individually. Do not look at or discuss solutions with anyone other than the instructor or the TAs. Do not copy or look at specific solutions from the net. Preparation 1. Download: http://www.cs.ou.edu/~fagg/classes/cs2334/labs/lab4/lab4.zip 2. Import into your Eclipse Workspace: (a) File menu: Import (b) Select General/Existing Projects into Workspace and then click Next (c) Select archive file: browse to the lab4.zip file (d) Click Finish 3. Once you create the new project, it may not initially know where to find the standard Java libraries (it varies depending on your configuration). (a) Project menu: Select properties (b) Select Java Build Path / Libraries (c) If the JRE System Library is not listed, then select Add library: JRE System Library and click Next. Select Workspace default. Click OK (d) If the JUnit Library is not listed, then select Add library: JUnit and click Next. Select JUnit 4. Click Finish (e) Click Apply and then OK 2

Representing Assignments Below is the UML representation of a set of classes that represent items that are used to compute your course grade. Your task is to implement this set of classes and the associated set of JUnit tests. Driver +main(args:string[]):void AssignmentList -itemlist:arraylist<assignment> +AssignmentList() +additem(item:assignment):void +computecoursegrade():double +tostring():string * -name:string -month:int -day:int -hour:int -minute:int -score:double -totalpoints:double -totalweight:double Assignment +Assignment(name:String, month:int, day:int, hour:int, minute:int) +getname():string +getmonth():int +getday():int +gethour():int +getminute():int +getscore():double +gettotalpoints():double +gettotalweight():double +setscore(score:double):void +settotalpoints(points:double):void +settotalweight(weight:double):void +tostring():string Lab -specification:string +Lab(name:String, month:int, day:int, hour:int, minute:int, specification:string) +tostring():string Project -specification:string -datafile:string +Project(name:String, month:int, day:int, hour:int, minute:int, specification:string, datafile:string) +tostring():string The line from Lab to Assignment indicates that a Lab is-a Assignment. You should use inheritance to capture this relationship. Likewise, for the Project and Assignment classes. 3

The line from AssignmentList to Assignment indicates that AssignmentList has-a Assignment. Observe that there is an itemlist attribute (instance variable) in the middle section of the AssignmentList box. Other than including this attribute, there is nothing special to be done for a has-a relationship. The * on this relationship indicates that the AssignmentList can have any number of Assignment objects. This fact is captured in the AssignmentList through the use of the ArrayList of Assignment (this is the meaning of the ArrayList<Assignment> notation in the type definition). How much a particular Assignment contributes to your course grade is determined by three properties: 1. score is the number of points that you have received on the assignment, 2. totalpoints is the number of points that are possible for the assignment, and 3. totalweight is the weight of this Assignment relative to other assignments. AssignmentList.computeCourseGrade() returns your score for the class based on the list of assignments. In particular: return = n 1 i=0 (totalw eight i score i /totalp oints i ) n 1 i=0 totalw eight i where n is the total number of Assignments in the list, and totalw eight i refers to the totalw eight of the i th Assignment. If n = 0, then the returned course grade must be zero. Lab 4: Specific Instructions 1. We have provided a complete implementation of the AssignmentTest class, and partial implementations of the AssignmentList and Driver classes. 2. Create a new Java class for each of the Assignment, Lab and Project classes, as described in the UML diagram. ˆ Be sure that the class name is exactly as shown ˆ You must use the default package, meaning that the package field must be left blank when you create the class 3. Implement the designated attributes and methods for each class: 4

ˆ Use the same spelling and visibility for instance variables and method names as shown in the UML ˆ Do not add functionality to the classes beyond what has been specified ˆ Don t forget to document as you go! 4. Assignment.toString(): for a Assignment item by the name of Unit Testing, a month of 12, day of 1, hour of 23, minutes of zero, score of 0.78, totalpoints of 0.99 and totalweight of 0.30, tostring() must return a String in the following format: U n i t T e s t i n g ( d a t e : 12 01 a t 2 3 : 0 0 ) : s c o r e = 0. 7 8 ; t o t a l P o i n t s = 0. 9 9 ; t o t a l W e i g h t = 0. 3 0 Note that each of month, day, hour and minute must be represented using exactly two digits, and that the score, totalpoints and totalweight must have exactly two digits following the decimal point. The location and number of spaces must also match this format. 5. Lab.toString(): for the same Unit Testing object as above and a specification of UnitTesting.pdf, tostring() must return a String in the following format: U n i t T e s t i n g ( d a t e : 12 01 a t 2 3 : 0 0 ) : s c o r e = 0. 7 8 ; t o t a l P o i n t s = 0. 9 9 ; t o t a l W e i g h t = 0. 3 0 ; s p e c i f i c a t i o n = U n i t T e s t i n g. p d f Note that in the box above, the left arrow character and the following newline are not part of the returned String (they were added so that the String would fit in this document). This tostring() method must make use of the Assignment.toString() method. 6. Project.toString(): for the same Unit Testing object as above, and a specification of UnitTesting.pdf and datafile of Snacks.csv, tostring() must return a String in the following format: U n i t T e s t i n g ( d a t e : 12 01 a t 2 3 : 0 0 ) : s c o r e = 0. 7 8 ; t o t a l P o i n t s = 0. 9 9 ; t o t a l W e i g h t = 0. 3 0 ; s p e c i f i c a t i o n = U n i t T e s t i n g. p d f ; d a t a f i l e = S n a c k s. c s v This tostring() method must make use of the Assignment.toString() method. 7. Examine our AssignmentList.toString() implementation. It returns a String that is a concatenation of all of the individual items in the list, with a newline 5

character ( \n ) after each item. The order of the items is the same order in which they were added to the AssignmentList. 8. Create JUnit classes to thoroughly test all of your code (called ProjectTest, LabTest and AssignmentListTest) ˆ You need to convince yourself that all of your primary classes are covered and that they are working properly ˆ We will test your code with a separate set of unit tests Final Steps 1. Generate Javadoc using Eclipse. ˆ Select Project/Generate Javadoc... ˆ Make sure that your lab4 project is selected, as are all of your Java files ˆ Select your doc directory ˆ Select Private visibility ˆ Use the default destination directory ˆ Click Finish 2. Open the lab4/doc/index.html file using your favorite web browser or Eclipse (double clicking in the package explorer will open the web page). Check to make sure that all of your classes are listed and that all of your documented methods have the necessary documentation. 3. If you complete the above instructions during lab, you may have your implementation checked by one of the TAs. Submission instructions ˆ All required components (source code and compiled documentation) are due at 7pm on Saturday, September 16) Submission must be done through the Web-Cat server. ˆ Use the same submission process as you used in lab 1. You must submit your implementation to the Lab 4: Inheritance area on the Web-Cat server. 6

Hints ˆ See the API for ArrayList ˆ See the method String.format() 7

Rubric The project will be graded out of 100 points. The distribution is as follows: Correctness/Testing: 45 points The Web-Cat server will grade this automatically upon submission. Your code will be compiled against a set of tests (called Unit Tests). These unit tests will not be visible to you, but the Web-Cat server will inform you as to which tests your code passed/failed. This grade component is a product of the fraction of our tests that your code passes and the fraction of your code that is covered by your tests. In other words, your submission must perform well on both metrics in order to receive a reasonable grade. Style/Coding: 20 points The Web-Cat server will grade this automatically upon submission. Every violation of the Program Formatting standard described in Lab 1 will result in a subtraction of a small number of points (usually two points). Looking at your submission report on the Web-Cat server, you will be able to see a notation for each violation that describes the nature of the problem and the number of subtracted points. Design/Readability: 35 points This element will be assessed by a grader (typically sometime after the lab deadline). Any errors in your program will be noted in the code stored on the Web-Cat server, and two points will be deducted for each. Possible errors include: ˆ Non-descriptive or inappropriate project- or method-level documentation (up to 10 points) ˆ Missing or inappropriate inline documentation (2 points per violation; up to 10 points) ˆ Inappropriate choice of variable or method names (2 points per violation; up to 10 points) ˆ Inefficient implementation of an algorithm (minor errors: 2 points each; up to 10 points) ˆ Incorrect implementation of an algorithm (minor errors: 2 points each; up to 10 points) 8

If you do not submit compiled Javadoc for your project, 5 points will be deducted from this part of your score. Note that the grader may also give warnings or other feedback. Although no points will be deducted, the issues should be addressed in future submissions(where points may be deducted). Bonus: up to 5 points You will earn one bonus point for every two hours that your assignment is submitted early. Penalties: up to 100 points You will lose ten points for every minute that your assignment is submitted late. For a submission to be considered on time, it must arrive at the server by the designated minute (and zero seconds). For a deadline of 9:00, a submission that arrives at 9:00:01 is considered late (in this context, it is one minute late). After 15 submissions to Web-Cat, you will be penalized one point for every additional submission. For labs, the server will continue to accept submissions for three days after the deadline. In these cases, you will still have the benefit of the automatic feedback. However, beyond ten minutes late, you will receive a score of zero. The grader will make their best effort to select the submission that yields the highest score. 9