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

You are currently viewing the BOOK: Beginning Java 2, JDK 5 Edition 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 October 25th, 2010, 11:26 AM
Registered User
Join Date: Oct 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Logic error in Exercise answers (chapter 5, ex.1)

I have had this book for an embarrassingly long time but I finally got round to reading it.
Did exercise 1 for chapter 5, rectangle class (page 267 in my copy), then d/l ans from wrox site
However you have the logic wrong in your Rectangle constructor quoted below...
public Rectangle(double x1, double y1, double x2, double y2) {
    // Ensure topleft uses the smaller of x1,x2 and y1,y2
    // and topright uses the larger of x1,x2 and y1,y2
    topLeft = new Point(Math.min(x1,x2),Math.min(y1,y2));
    bottomRight = new Point(Math.max(x1,x2),Math.max(y1,y2));
Top left is minX maxY
and bottom right is maxX and MinY
I just thought I would let you know, someone might have "given up" when they got it right!

Last edited by stalinvlad; October 25th, 2010 at 11:28 AM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exercise answers now available jminatel BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 January 2nd, 2005 11:26 AM
Beginning Visual C# Exercise Answers EAK Wrox Book Feedback 1 June 4th, 2003 08:48 PM

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