evilcow

Member
Aug 5, 2001
91
0
0
BalloonClass.java:
// import the packages!
import hsa.Console;
import java.awt.*;

class BalloonClass
{
// declare a console object + global variables for this class.
protected static Console c;
protected static int i_radius = 50;
protected static int i_stringlength = 50;
protected static int i_x = 200;
protected static int i_y = 250;
protected static int i_maxradius = 149;
protected static boolean b_pop = false;
protected static Color i_color;


//class constructor
public BalloonClass (Console c)
{
//refers to the c in the balloonclass, not an argument
this.c = c;
}



//draw method for a balloon.
public void draw ()
{
// make a circle!
c.setColour (i_color);
c.fillOval (i_x, i_y, i_radius, i_radius);
c.setColour (i_color);
c.drawLine (i_x + (i_radius / 2), i_radius + i_y, i_x + (i_radius / 2), i_radius + i_stringlength + i_y);
}


//erase method for a balloon.
public void erase ()
{
Color c_tmp = getcolor ();
//erase it!
i_color = Color.white;
draw ();
//set the old color back!
i_color = c_tmp;
}


//delay method.
public void delay (int idelay)
{
double garbage;
for (int i = 1 ; i <= idelay * 5000 ; i++)
{
garbage = Math.PI * Math.PI;
}
}


//shrink method [action]
public void shrink (int ifinalradius)
{
if (b_pop != true)
{
while (ifinalradius <= i_radius && b_pop != true)
{
if (i_radius > i_maxradius)
{
b_pop = true;
pop ();
}
else
{
i_radius -= 1;
draw ();
delay (20);
erase ();
}
}
if (b_pop != true)
{
draw ();
}
}
}


//grow method [action]
public void grow (int ifinalradius)
{
if (b_pop != true)
{
while (ifinalradius >= i_radius && b_pop != true)
{
if (i_radius > i_maxradius)
{
b_pop = true;
pop ();
}
else
{
i_radius += 1;
draw ();
delay (20);
erase ();
}
}
if (b_pop != true)
{
draw ();
}
}
}


//point check method
public boolean checkpoint (int x, int y)
{
boolean b_check = false;
if (Math.sqrt (Math.pow((x - i_x), 2) + Math.pow((y - i_y), 2)) <= i_radius)
{
b_check = true;
}
return (b_check);
}


//pop method [action]
public void pop ()
{
erase ();
c.setColor (i_color);
c.drawLine (i_x + (i_radius / 2), i_radius + i_y, i_x + (i_radius / 2), i_radius + i_stringlength + i_y);
c.setColour (Color.yellow);
c.fillStar (i_x, i_y, i_radius, i_radius);
delay (100);
c.setColour (Color.red);
c.fillStar (i_x, i_y, i_radius, i_radius);
delay (100);
c.setColour (Color.yellow);
c.fillStar (i_x, i_y, i_radius, i_radius);
delay (100);
c.setColour (Color.red);
c.fillStar (i_x, i_y, i_radius, i_radius);
delay (100);
c.setColour (Color.white);
c.fillStar (i_x, i_y, i_radius, i_radius);
}




//communicate methods.
public void setradius (int newradius)
{
i_radius = newradius;
}


public int getradius ()
{
return (i_radius);
}


public void setxy (int newx, int newy)
{
i_x = newx;
i_y = newy;
}


public int getx ()
{
return (i_x);
}


public int gety ()
{
return (i_y);
}


//remember color is a type ;D
public void setcolor (Color newcolor)
{
i_color = newcolor;
}


public Color getcolor ()
{
return (i_color);
}


public void setstringlength (int newstringlength)
{
i_stringlength = newstringlength;
}


public int getstringlength ()
{
return (i_stringlength);
}


public void setmaxradius (int newmaxradius)
{
i_maxradius = newmaxradius;
}


public int getmaxradius ()
{
return (i_maxradius);
}
}


--------------------------------------------------------------------------------------------------------------------------

PinClass.java:
// import the packages!
import hsa.Console;
import java.awt.*;

class PinClass
{
// declare a console object + global variables for this class.
protected static Console c;
protected static int i_headx = 100;
protected static int i_heady = 100;
protected static int i_tailx = 200;
protected static int i_taily = 200;
protected static Color i_color;


//class constructor
public PinClass (Console c)
{
this.c = c;
}

//draw method for a pin.
public void draw ()
{
// instantiate a Console object from the hsa.Console package

c.setColour (i_color);
c.fillOval (i_headx, i_heady, 5, 5);
c.drawLine (i_headx, i_heady, i_tailx, i_taily);
}


//erase method for a balloon.
public void erase ()
{
Color c_tmp = getcolor ();
//erase it!
c.setColour (Color.white);
draw ();
//set the old color back!
c.setColour (c_tmp);
}


//delay method.
public void delay (int idelay)
{
double garbage;
for (int i = 1 ; i <= idelay * 5000 ; i++)
{
garbage = Math.PI * Math.PI;
}
}


//communicate methods.
public void setheadxy (int newx, int newy)
{
i_headx = newx;
i_heady = newy;
}


public void settailxy (int newx, int newy)
{
i_tailx = newx;
i_taily = newy;
}


public int getheadx ()
{
return (i_headx);
}


public int getheady ()
{
return (i_heady);
}


public int gettailx ()
{
return (i_tailx);
}


public int gettaily ()
{
return (i_taily);
}


//remember color is a type ;D
public void setcolor (Color newcolor)
{
i_color = newcolor;
}


public Color getcolor ()
{
return (i_color);
}
}

--------------------------------------------------------------------------------------------------------------------------

UsePinBalloonClass.java:
import java.awt.*;
import hsa.Console;

class UsePinBalloon
{
public static void main (String [] args)
{
// console object
Console c;
c = new Console ();
int i = 0;
boolean bpopped = false;

//generate 2 pins + 2 balloons
PinClass p [] = new PinClass [100];
BalloonClass b = new BalloonClass (c);
b.setxy (((int) (Math.random () * 600) + 1), ((int) (Math.random () * 400) + 1));
b.draw ();
while (i < 100 && bpopped != true)
{
i += 1;
p = new PinClass (c);
p .setheadxy (((int) (Math.random () * 600) + 1), ((int) (Math.random () * 400) + 1));
p .settailxy (((int) (Math.random () * 600) + 1), ((int) (Math.random () * 400) + 1));
p .draw ();
p .delay (1000);
if (b.checkpoint (p .gettailx (), p .gettaily ()) == true)
{
bpopped = true;
b.pop ();
}
}

}
}
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |