Lab Exercise 6 CS 2334

Similar documents
Assignment 1: Due Friday Feb 6 at 6pm

Collisions and conservation laws

Without fully opening the exam, check that you have pages 1 through 10.

Please allow yourself one to two hours to complete the following sections of the packet. College Integrated Geometry Honors Integrated Geometry

Unit 7 Trigonometry Project Name Key Project Information

STUDENT NAME: STUDENT SIGNATURE: STUDENT ID NUMBER: SECTION NUMBER AND RECITATION INSTRUCTOR:

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University

POC via CHEMnetBASE for Identifying Unknowns

MTH 234 Exam 1 February 20th, Without fully opening the exam, check that you have pages 1 through 11.

Without fully opening the exam, check that you have pages 1 through 11.

AST101: Our Corner of the Universe Take Home Lab: Observing the Moon and the Sun

MA EXAM 3 INSTRUCTIONS VERSION 01 April 18, Section # and recitation time

MA EXAM 1 INSTRUCTIONS VERSION 01 September 13, Section # and recitation time

CS Exam 1 Study Guide and Practice Exam

Without fully opening the exam, check that you have pages 1 through 11.

MATH 137 : Calculus 1 for Honours Mathematics. Online Assignment #2. Introduction to Sequences

MA EXAM 3 INSTRUCTIONS VERSION 01 April 14, Section # and recitation time

Name: Period: Date: CHEMISTRY LAB #4 THE ILLUSION OF BLING: Using Density to Identify an Unknown Metal 90 MINUTES

MA EXAM 3 INSTRUCTIONS VERSION 01 April 17, Section # and recitation time

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Fall 2016

first name (print) last name (print) brock id (ab17cd) (lab date)

Ideal Gas Law and Absolute Zero

MA EXAM 1 INSTRUCTIONS VERSION 01 FEBRUARY 8, Section # and recitation time

MA EXAM 2 INSTRUCTIONS VERSION 01 March 9, Section # and recitation time

Modeling the Motion of a Projectile in Air

Elizabethtown Area School District Chemistry in Your World

MA Exam 1 Fall 2015 VERSION 01

Without fully opening the exam, check that you have pages 1 through 11.

Representations of Motion in One Dimension: Speeding up and slowing down with constant acceleration

STUDY GUIDE 1: Introduction, Vectors, Kinematics

PHY 134 Lab 3 - Capacitors

MA162 EXAM III SPRING 2017 APRIL 11, 2017 TEST NUMBER 01 INSTRUCTIONS:

CS246: Mining Massive Data Sets Winter Only one late period is allowed for this homework (11:59pm 2/14). General Instructions

Learning ArcGIS: Introduction to ArcCatalog 10.1

Student s Printed Name:

Physics Grading Sheet.

Ocean Optics Red Tide UV-VIS Spectrometer (Order Code: SPRT-UV-VIS)

Test 3 Version A. On my honor, I have neither given nor received inappropriate or unauthorized information at any time before or during this test.

Methods of Measurement

Lab 6 - Electron Charge-To-Mass Ratio

Working with Digital Elevation Models in ArcGIS 8.3

Physics Fall Semester. Sections 1 5. Please find a seat. Keep all walkways free for safety reasons and to comply with the fire code.

Math 180 Written Homework Assignment #10 Due Tuesday, December 2nd at the beginning of your discussion class.

Homework 6: Image Completion using Mixture of Bernoullis

AP PHYSICS 2011 SCORING GUIDELINES

STUDENT NAME: STUDENT SIGNATURE: STUDENT ID NUMBER: SECTION NUMBER AND RECITATION INSTRUCTOR:

New Zealand Population Distribution

MA 161 EXAM 3 GREEN November 14, You must use a #2 pencil on the scantron sheet (answer sheet).

Determining the Conductivity of Standard Solutions

Without fully opening the exam, check that you have pages 1 through 12.

Assignment 4: Rigid Body Dynamics

Homework Assignment 4 Root Finding Algorithms The Maximum Velocity of a Car Due: Friday, February 19, 2010 at 12noon

Module 1: What is Earth Science? Topic 3 Content: Measuring Mass and Volume Presentation Notes. Measuring Mass and Volume

Physics 2BL: Experiments in Mechanics and Electricity Summer Session I, 2012

Visual Physics Forces & Acceleration Lab 3

Introduction to ArcGIS Server Development

MA EXAM 2 INSTRUCTIONS VERSION 01 March 10, Section # and recitation time

HONORS CHEMISTRY Bonding Unit Summative Assessment

Exercises for Windows

How to Create Stream Networks using DEM and TauDEM

Section 6: Polynomials

7. STREAMBED TEXTURE ANALYSIS

first name (print) last name (print) brock id (ab17cd) (lab date)

1 ListElement l e = f i r s t ; / / s t a r t i n g p o i n t 2 while ( l e. next!= n u l l ) 3 { l e = l e. next ; / / next step 4 } Removal

Assignment 1: Probabilistic Reasoning, Maximum Likelihood, Classification

MARS PUBLIC MAPPING PROJECT (MP)2

STUDY GUIDE 4: Equilibrium, Angular Kinematics, and Dynamics

ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK

Physics 210 Q ( PHYSICS210BRIDGE ) My Courses Course Settings

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course

Creating Empirical Calibrations

Lab 3. Newton s Second Law

Student s Printed Name:

PHYSICS 221 Fall 2013 EXAM 2: November 6, :15pm 10:15pm. Name (printed): Recitation Instructor: Section #:

CMPT 310 Artificial Intelligence Survey. Simon Fraser University Summer Instructor: Oliver Schulte

CS 420/594: Complex Systems & Self-Organization Project 1: Edge of Chaos in 1D Cellular Automata Due: Sept. 20

Test 3 - Answer Key Version B

Lab 1: Earthquake Resources & Plotting Epicenters

AP PHYSICS SUMMER WORK

New York State Testing Program Grade 8 Common Core Mathematics Test. Released Questions with Annotations

POC via CHEMnetBASE for Identifying Unknowns

Flight Utilities Metar Reader version 3.1 by Umberto Degli Esposti

Conformational Analysis of n-butane

LAB 01 Electrostatic Charge

Chemistry 14CL. Worksheet for the Molecular Modeling Workshop. (Revised FULL Version 2012 J.W. Pang) (Modified A. A. Russell)

HEC-HMS Lab 2 Using Thiessen Polygon and Inverse Distance Weighting

MATHS QUEST 8 for the Australian Curriculum

Organic Chemistry Syllabus

Without fully opening the exam, check that you have pages 1 through 10.

Lab 5 - ELECTRON CHARGE-TO-MASS RATIO

The Geodatabase Working with Spatial Analyst. Calculating Elevation and Slope Values for Forested Roads, Streams, and Stands.

Measurement of Mass, Length, and Time

Mass Asset Additions. Overview. Effective mm/dd/yy Page 1 of 47 Rev 1. Copyright Oracle, All rights reserved.

Lab 5 - ELECTRON CHARGE-TO-MASS RATIO

Data Structures & Database Queries in GIS

MA EXAM 3 Form A April 16, You must use a #2 pencil on the mark sense sheet (answer sheet).

Homework Assignment 2 Modeling a Drivetrain Model Accuracy Due: Friday, September 16, 2005

Without fully opening the exam, check that you have pages 1 through 11.

Conservation of Mechanical Energy Activity Purpose

Transcription:

Lab Exercise 6 CS 2334 September 28, 2017 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces. You will implement a set of classes that represent various 3D shapes. In addition, your implementation will facilitate the comparison of shape objects, even when they are of different shape classes. Learning Objectives By the end of this laboratory exercise, you should be able to: 1. Create and extend abstract classes and methods 2. Use interfaces to define standard behavior across multiple classes 3. Appropriately select an abstract class or interface based on the requirements of the solution 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. 1

Preparation Download the lab6 implementation: http://www.cs.ou.edu/~fagg/classes/cs2334/labs/lab6/lab6.zip Representing Different Shapes Below is the UML representation of a set of classes that represent various 3D shapes. Your task will be to implement this set of classes and an associated set of JUnit test procedures. Comparator «interface» ShapeComparator +compare(s1:shape, s2:shape):int +equals(s1:shape, s2:shape):boolean -numshapes -id: int Shape +Shape() +getnumshapes():int +getid():int +compareto(shape s):int +tostring():string +getvolume():double +getsurfacearea():double Comparable «Interface» Driver +main(args:string[]):void Sphere -radius:double +Sphere(radius:double) +getsurfacearea():double +getvolume():double +getradius():double +tostring():string -length:double -breadth:double -height:double Cuboid +Cuboid(length:double,breadth:double, height:double) +getsurfacearea():double +getvolume():double +getlength():double +getbreadth():double +getheight():double +tostring():string -height:double -radius:double Cylinder +Cylinder(height:double, radius:double) +getvolume():double +getsurfacearea():double +getheight():double +getradius():double +tostring():string Cube +Cube(edge:double) The classes in italics represent abstract classes or interfaces. Note that Comparable and Comparator are defined in the Java library. The concrete child classes 2

must implement all methods from the abstract parent classes. In this lab, Shape is an abstract class. The line from Shape to Comparable indicates that Shape must implement the Comparable interface. The Shape class compares shape objects based on their surface areas and then their volumes. In contrast, the ShapeComparator class must implement the Comparator interface. ShapeComparator compares shape objects based on their volume only. You must provide both the compare() and equals() methods. All instances of a Shape are given a unique int id. These are to be assigned by the Shape constructor. The first instance of a shape that is created is assigned an id of 0 (zero); the next is assigned 1. numshapes is a static variable that will be incremented each time a new 3D Shape object is created and keeps track of the total number of 3D Shape objects that have been created. In the Cube class, the lengths of the three sides i.e length, breadth and height are equal to edge length. Lab 6: Specific Instructions Start from the class files that are provided in lab6.zip. 1. Import lab6.zip into your Eclipse workspace. 2. Implement the attributes and methods for each class ˆ Complete the implementation of the Shape and Cube classes. Implement the Sphere, Cuboid, and ShapeComparator classes. Complete implementations of the Cylinder and Driver classes have been provided. ˆ 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! 3. Create JUnit test for all the methods implemented in the above classes. ˆ You need to convince yourself that everything is working properly. ˆ Make sure that you cover all the classes and methods while creating your tests. Keep in mind that we have our own tests that we will use for grading. 3

Notes 1. Examine Cylinder.toString(). For a Cylinder item with ID = 1, shapetype = Cylinder, SurfaceArea = 31.42, Volume = 12.57, height = 4.00 and radius = 1.00, tostring() returns a String in the following format: C y l i n d e r : I D = 1 S u r f a c e A r e a = 3 1. 4 2 V o l u m e = 1 2. 5 7 h e i g h t = 4. 0 0 r a d i u s = 1. 0 0 Note that each of Surface Area, Volume, height and radius are represented using exactly two digits following the decimal point. The whitespace preceding each variable name is implemented with a single tab character ( \t ). There is also one space on either side each equal sign. 2. Sphere.toString(): for a Sphere object with ID = 0, shapetype = Sphere, SurfaceArea = 201.06, Volume = 268.08 and radius = 4.00, tostring() must return a String in the following format: S p h e r e : I D = 0 S u r f a c e A r e a = 2 0 1. 0 6 V o l u m e = 2 6 8. 0 8 r a d i u s = 4. 0 0 The format follows the same pattern as the Cylinder class. 3. Cuboid.toString(): for a Cuboid object with ID = 2, shapetype = Cuboid, a SurfaceArea = 94.00, Volume = 60.00, length = 3.00, breadth = 4.00 and height = 5.00, tostring() must return a String in the following format: C u b o i d : I D = 2 S u r f a c e A r e a = 9 4. 0 0 V o l u m e = 6 0. 0 0 l e n g t h = 3. 0 0 b r e a d t h = 4. 0 0 h e i g h t = 5. 0 0 Note that the left arrow is not part of the String (it only indicates that the full String does not fit on the width of this page). 4. The Shape class, through Comparable interface, compares the shape objects based on their surface areas (in ascending order); if their surface areas are identical, the comparison is based on their volume (again, in ascending order). An example list of objects after sorting is as follows: C u b o i d : I D = 2 S u r f a c e A r e a = 6. 0 0 V o l u m e = 1. 0 0 l e n g t h = 1. 0 0 b r e a d t h = 1. 0 0 h e i g h t = 1. 0 0 C y l i n d e r : I D = 1 S u r f a c e A r e a = 1 2. 5 7 V o l u m e = 3. 1 4 h e i g h t = 1. 0 0 r a d i u s = 1. 0 0 S p h e r e : I D = 0 S u r f a c e A r e a = 1 2. 5 7 V o l u m e = 4. 1 9 r a d i u s = 1. 0 0 C u b e : I D = 3 S u r f a c e A r e a = 5 4. 0 0 V o l u m e = 2 7. 0 0 l e n g t h = 3. 0 0 b r e a d t h = 3. 0 0 h e i g h t = 3. 0 0 C u b e : I D = 4 S u r f a c e A r e a = 9 6. 0 0 V o l u m e = 6 4. 0 0 l e n g t h = 4. 0 0 b r e a d t h = 4. 0 0 h e i g h t = 4. 0 0 4

5. The ShapeComparator class, through the Comparator interface, compares the shape objects based on their Volume (in descending order). An example list of Shapes after sorting with the ShapeComparator is as follows: C u b e : I D = 4 S u r f a c e A r e a = 9 6. 0 0 V o l u m e = 6 4. 0 0 l e n g t h = 4. 0 0 b r e a d t h = 4. 0 0 h e i g h t = 4. 0 0 C u b e : I D = 3 S u r f a c e A r e a = 5 4. 0 0 V o l u m e = 2 7. 0 0 l e n g t h = 3. 0 0 b r e a d t h = 3. 0 0 h e i g h t = 3. 0 0 S p h e r e : I D = 0 S u r f a c e A r e a = 1 2. 5 7 V o l u m e = 4. 1 9 r a d i u s = 1. 0 0 C y l i n d e r : I D = 1 S u r f a c e A r e a = 1 2. 5 7 V o l u m e = 3. 1 4 h e i g h t = 1. 0 0 r a d i u s = 1. 0 0 C u b o i d : I D = 2 S u r f a c e A r e a = 6. 0 0 V o l u m e = 1. 0 0 l e n g t h = 1. 0 0 b r e a d t h = 1. 0 0 h e i g h t = 1. 0 0 6. The formulas for the 3D Shape Classes are as follows: Class Surface Area Volume Shape Type Sphere 4πr 2 4 3 πr3 Sphere Cuboid 2 (l b + b h + h l) l b h Cuboid Cylinder 2πr (r + h) hπr 2 Cylinder Cube 6l 2 l 3 Cube Final Steps 1. Generate Javadoc using Eclipse. ˆ Select Project/Generate Javadoc... ˆ Make sure that your lab6 project is selected, as are all of your java files ˆ Select your doc directory ˆ Select Private visibility ˆ Use the default destination folder ˆ Click Finish 2. Open the lab6/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 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. 5

Submission Instructions Before submission, finish testing your program by executing your unit tests. If your program passes all tests and your classes are covered completely by your test classes, then you are ready to attempt a submission. Here are the details: ˆ All required components (source code and compiled documentation) are due at 7pm on Saturday, September 30. 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 6: Abstract Classes and Interfaces area on the Web- Cat server. Reading ˆ API for the Collections Framework ˆ Comparable interface. ˆ Comparator interface. 6

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) 7

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. 8