Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Beginning Java 2
|
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2005, 11:03 AM
Registered User
 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default solution 1 in exercises in chapter 6

hey guys i can't understand this particular code:

class Rectangle extends Shape{
 public Rectangle(Point startDiag, Point endDiag) {
  // Bottom right is relative to top left:
    bottomRight = new Point(Math.max(startDiag.x,endDiag.x) - position.x, Math.max(startDiag.y,endDiag.y) - position.y);
 }
  //rest of the code
}

in bottomRight why the new points need to be subtracted from postion.x and position.y? in comment is says "bottom right is relative to top left" i can't see it's relevance.
Where you can simply write it:

 bottomRight = new Point(Math.max(startDiag.x,endDiag.x),
                         Math.max(startDiag.y,endDiag.y));

instead of:

 bottomRight = new Point(Math.max(startDiag.x,endDiag.x) - position.x,
                         Math.max(startDiag.y,endDiag.y) - position.y);

thank guys i will really appreciate your help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
chapter 4 exercises #2-4 clue BOOK Beginning CSS: Cascading Style Sheets for Web Design, 2nd Ed; ISBN: 978-0-470-09697-0 3 March 24th, 2008 10:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.