Skip to content

adithyalaks/Assignment5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assignment 5 Readme.txt
Submitted by: Jacob McConnell 260706620,  Adithya Lakshminarayanan 260728234

Question 1: File, ca/mcgill/ecse202/a5/Question1.java  To run simply call “java Question1.java”. The associated class for this test program is MyRectangle2D.java. The test program creates a MyRectangle2D object r1 with center (2,2), and width and height of 5.5 and 4.9 units respectively. The test program will print out the area, perimeter, whether the point 3,3 is contained within the rectangle object, whether r1 contains a rectangle with center (4,5) and width and height of 10.5 and 3.2 respectively. Finally, the program will check whether r1 overlaps with a rectangle with center (3,5) and height and width of 2.3 and 5.4 respectively. 
 
Question 2: File, ca/mcgill/ecse202/a5/Question2.java To run simply call “java Question2.java”. The associated class for this project are GeometricObject.java (obtained from the appendix of the assignment description), and Triangle.java. The program will prompt the user to enter the lengths of the three sides of a triangle they wish to create, as well as the color of the triangle, and whether it is filled or not. The test program will create a Triangle object as specified, and will display the area, perimeter, color,  whether the triangle is filled or not, and will also provide a string representation of the triangle created. The associate UML diagram, called ‘UML_Question2.pdf’, can be found in the zip package, outside of the source code file.
 
Question 3: File, ca/mcgill/ecse202/a5/Question3.java To run simply call “java Question3.java”. The program will create an array of 100 randomly chosen integers. The user will then be prompted to the index of the element in the array that they wish to see. If they enter an index value that is out of bounds, they will be prompted with an exception, and will be asked to enter a new index value, until such a point that a valid index number is inputed. Once the user has inputed an appropriate index, the program will terminate.

Question 4: File ca/mcgill/ecse202/a5/Question4.java To run simply call “java Question4.java”. The associated classes for this test program are IllegalTriangleException.java (a class that defines an Illegal Triangle Exception object), and TriangleWithException.java. These associated classes are similar to that in question2, with the difference that a user will be prompted with an exception if they attempt to create a triangle object for which the sum of lengths any two sides is greater than the length of the remaining side. The test program creates two triangle objects (t1 and t2), the second of which is clearly violates the exception coded for. The test program will print out the perimeter and area for t1, but will illustrate that t2 is an illegal triangle, and will then print out the three sides for the triangle that was entered for t2. 



 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages