The Artima Developer Community
Sponsored Link

Java Answers Forum
confused about writing test driver

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Michelle Loh

Posts: 10
Nickname: modernage
Registered: Feb, 2006

confused about writing test driver Posted: Mar 5, 2006 11:55 PM
Reply to this message Reply
Advertisement
Hi, I want to test my code with a driver but i am not exactly sure on how to write one for this, can anyone give me an example to write one for a certain part of the code?

public class Window
{
private int top,left,width,height,x,y,amount,screenwidth,screenheight,horizontal,vertical,b ottomx,bottomy,othertop,otherbottomx,otherbottomy,otherleft;

public Window(int top, int left, int width, int height)
{
this.top=top;
this.left=left;
this.width=width;
this.height=height;
}
 
public int getTop()
{
return top;
}
 
public int getLeft()
{
return left;
}
 
public int getWidth()
{
return width;
}
 
public int getHeight()
{
return height;
}
 
public void moveTo(int x, int y)
{
left=x;
top=y;
}
 
public boolean resizeHorizontally(int amount)
{
horizontal=amount+width;
if (horizontal<0)
{
return false;
}
width=width+amount;
return true;
 
}
 
public boolean resizeVertically(int amount)
{
vertical=amount+height;
if (vertical<0)
{
return false;
}
 
height=height+amount;
 
return true;
}
 
public boolean contains(int x, int y)
{
 
bottomx=left+width-1;
bottomy=top+height-1;
if (x>=left && x<=bottomx && y>=top && y<=bottomy)
{
return true;
}
return false;
}
 
public boolean isCompletelyOnscreen(int screenwidth, int screenheight)
{
bottomx=left+width-1;
bottomy=top+height-1;
screenwidth=screenwidth-1;
screenheight=screenheight-1;
if (left>=0 && left<=screenwidth && top>=0 && top<=screenheight && bottomx>=0 && bottomx<=screenwidth && bottomy>=0 && bottomy<=screenheight)
{
return true;
}
return false;
}
 
 
public boolean overlaps(Window other)
{
otherleft=other.getLeft();
othertop=other.getTop();
otherbottomx=other.getLeft()+other.getWidth()-1;
otherbottomy=other.getTop()+other.getHeight()-1;
if (otherbottomx>=left && otherbottomx<=bottomx && othertop<=bottomy && otherbottomy>=top)
{
return true;
}
if (otherleft>=left && otherleft<=bottomx && othertop<=bottomy && otherbottomy>=top)
{
return true;
}
if (otherbottomx>=left && otherbottomx<=bottomx && othertop<=bottomy && otherbottomy>=bottomy)
{
return true;
}
if (otherleft>=left && otherleft<=bottomx && othertop<=bottomy && otherbottomy>=bottomy)
{
return true;
}
 
return false;
 
 
}
}

Topic: need help in a program!! Previous Topic   Next Topic Topic: help plz...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use