id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav.gupta@mq.edu.au conditions > squaresOverlapping
prev  |  next  |  chance

Define a function that when passed 6 parameters (I know, it's a bit more than we'd usually like), representing,

1. x-coordinate of top-left point of first square 2. y-coordinate of top-left point of first square 3. length of each side of first square 4. x-coordinate of top-left point of second square 5. y-coordinate of top-left point of second square 6. length of each side of second square

returns true if the two squares overlap (even by a little bit).

For example, a square with side 10 and top-left corner at (10, 20) and a square with side 5 and top-left corner at (20, 25), share one point in common (20, 20), so they do overlap.


squaresOverlapping(10, 20, 10, 20, 30, 5) → true
squaresOverlapping(20, 50, 30, 40, 90, 10) → false
squaresOverlapping(20, 50, 30, 40, 70, 10) → true

...Save, Compile, Run (ctrl-enter)

boolean squaresOverlapping(int x1, int y1, int side1, int x2, int y2, int side2) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 5 Post-solution available

Copyright Nick Parlante 2017 - privacy