Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * INFO0062 - Object-oriented programming
- * Special session (16/05/2019)
- *
- * Example of main() to test the LineSegment class described by the first question from the
- * written examination of May 2018. This question didn't asked students to write a main(), so the
- * main() here is just a way of testing the code. You should only write a main() method if and
- * only if the question explicitely requests it.
- *
- * @author: J.-F. Grailet
- */
- public class Main
- {
- public static void main(String args[])
- {
- LineSegment l1 = new LineSegment(1, 1, 1, 2, 2, 2);
- LineSegment l2 = new LineSegment(1, 2, 3, 4, 5, 6);
- LineSegment l3 = (LineSegment) l1.clone();
- if(l1.equals(l2))
- System.out.println(l1 + " and " + l2 + " are equal.");
- else
- System.out.println(l1 + " and " + l2 + " aren't equal.");
- if(l1.equals(l3))
- System.out.println(l1 + " and " + l3 + " are equal.");
- else
- System.out.println(l1 + " and " + l3 + " aren't equal.");
- l2.translate(3, 3, 3);
- l3.translate(1, 2, 3);
- System.out.println(l2);
- if(l1.equals(l3))
- System.out.println(l1 + " and " + l3 + " are equal.");
- else
- System.out.println(l1 + " and " + l3 + " aren't equal.");
- try
- {
- LineSegment[] split = l1.split();
- System.out.println("Split of " + l1 + ": " + split[0] + " and " + split[1]);
- }
- catch(Exception e)
- {
- System.err.println("Error: " + e.getMessage());
- }
- try
- {
- LineSegment[] split = l2.split();
- System.out.println("Split of " + l2 + ": " + split[0] + " and " + split[1]);
- }
- catch(Exception e)
- {
- System.err.println("Error: " + e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement