• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 14:22
CET 20:22
KST 04:22
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament RSL Offline Finals Info - Dec 13 and 14! StarCraft Evolution League (SC Evo Biweekly) RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
[ASL20] Ask the mapmakers — Drop your questions BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET [BSL21] RO16 Group B - Sunday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread ZeroSpace Megathread The Perfect Game Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
I decided to write a webnov…
DjKniteX
Physical Exertion During Gam…
TrAiDoS
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1298 users

The Big Programming Thread - Page 263

Forum Index > General Forum
Post a Reply
Prev 1 261 262 263 264 265 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
JonGalt
Profile Joined February 2013
Pootie too good!4331 Posts
March 06 2013 18:37 GMT
#5241
Hey guys, so I am making a website and I want to incorporate a user login system. I am using phpmyadmin, lubuntu 12.10, html 4, and mysql. The problem I am having is that whenever I try to register a user, my browser just downloads register.php instead of adding the user to the database.

I think it has something to do with my apache2 conf files, but I haven't nailed it down.

I edited etc/apache2/mods-available/php5.conf and I created a .htaccess file in the same directory as my index.html where all it has in it is: Type application/x-httpd-php5 .php .phtml

Point is, I am totally lost and would love some insight! I am new to website programming.
LiquidLegends StaffWho is Jon Galt?
tofucake
Profile Blog Joined October 2009
Hyrule19174 Posts
March 06 2013 19:57 GMT
#5242
do you have php installed and enabled?
Liquipediaasante sana squash banana
tuho12345
Profile Blog Joined July 2011
4482 Posts
March 07 2013 01:41 GMT
#5243
Hi everyone, I've been spending the last 2 days try to figure out but I gave up. It looks like a simple homework except I don't know how or where to start. Please help me with this Java problem

here's the question and code
+ Show Spoiler +

Write a graphics program that asks the user to specify the radii of two circles. The first circle has center (100, 200), and the second circle has center (200, 100). Draw the circles. If they intersect, then color both circles green. Otherwise, color them red. Hint: Compute the distance between the centers and compare it to the radii. Your program should draw nothing if the user enters a negative radius. In your exercise, declare a class Circle and a method boolean intersects(Circle other).

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

/**
This class implements a Circle. It includes a method to test whether
two circles intersect.
*/
public class Circle
{
private double xCenter;
private double yCenter;
private double radius;
private Color color;

/**
Constructs a black circle.
@param x the x-coordinate of the center
@param y the y-coordinate of the center
@param r the radius
*/
public Circle(double x, double y, double r)
{
xCenter = x;
yCenter = y;
radius = r;
color = Color.BLACK;
}

/**
Sets the color of this circle.
@param aColor the color
*/
public void setColor(Color aColor)
{
color = aColor;
}

/**
Draws the circles.
@param g2 the graphics context
*/
public void draw(Graphics2D g2)
{
if (radius < 0)
return;

g2.setColor(color);
// draw the circle
Ellipse2D.Double circle
= new Ellipse2D.Double(xCenter - radius, yCenter - radius,
2 * radius, 2 * radius);
g2.draw(circle);
}

/**
Tests whether or not the two circles intersect with each other.
@param other the other circle
@return true the two circles intersect
*/
public boolean intersects(Circle other)
{

double distance;
distance =......
radius = radius + other.radius;
if (distance <= radius)
{
return true;
}
else
{
return false;

}
}
}


tester file

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
Shows two Circles and tests whether they intersect or not.
*/
public class CircleComponent extends JComponent
{
private Circle circle1;
private Circle circle2;


/**
Constructs a component for showing two circles.
@param r1 the radius of the first circle
@param r2 the radius of the second circle
*/
public CircleComponent( double r1, double r2)
{
String message;

circle1 = new Circle(100, 200, r1);
circle2 = new Circle(200, 100, r2);
Color color;
if (........)
color = Color.GREEN;
else
color = Color.RED;
circle1.setColor(color);
circle2.setColor(color);
}

public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;

circle1.draw(g2);
circle2.draw(g2);
}
}



I think I have the idea of finding distance and compare it with radius, however I don't know what's the right formula for calculating distance cause I haven't touched trig since like 9th grade. Also for the if statement in the tester file, i keep having error with the parameter for the argument.
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2013-03-07 01:58:25
March 07 2013 01:51 GMT
#5244
On March 07 2013 10:41 tuho12345 wrote:
Hi everyone, I've been spending the last 2 days try to figure out but I gave up. It looks like a simple homework except I don't know how or where to start. Please help me with this Java problem

here's the question and code
+ Show Spoiler +

Write a graphics program that asks the user to specify the radii of two circles. The first circle has center (100, 200), and the second circle has center (200, 100). Draw the circles. If they intersect, then color both circles green. Otherwise, color them red. Hint: Compute the distance between the centers and compare it to the radii. Your program should draw nothing if the user enters a negative radius. In your exercise, declare a class Circle and a method boolean intersects(Circle other).

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

/**
This class implements a Circle. It includes a method to test whether
two circles intersect.
*/
public class Circle
{
private double xCenter;
private double yCenter;
private double radius;
private Color color;

/**
Constructs a black circle.
@param x the x-coordinate of the center
@param y the y-coordinate of the center
@param r the radius
*/
public Circle(double x, double y, double r)
{
xCenter = x;
yCenter = y;
radius = r;
color = Color.BLACK;
}

/**
Sets the color of this circle.
@param aColor the color
*/
public void setColor(Color aColor)
{
color = aColor;
}

/**
Draws the circles.
@param g2 the graphics context
*/
public void draw(Graphics2D g2)
{
if (radius < 0)
return;

g2.setColor(color);
// draw the circle
Ellipse2D.Double circle
= new Ellipse2D.Double(xCenter - radius, yCenter - radius,
2 * radius, 2 * radius);
g2.draw(circle);
}

/**
Tests whether or not the two circles intersect with each other.
@param other the other circle
@return true the two circles intersect
*/
public boolean intersects(Circle other)
{

double distance;
distance =......
radius = radius + other.radius;
if (distance <= radius)
{
return true;
}
else
{
return false;

}
}
}


tester file

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
Shows two Circles and tests whether they intersect or not.
*/
public class CircleComponent extends JComponent
{
private Circle circle1;
private Circle circle2;


/**
Constructs a component for showing two circles.
@param r1 the radius of the first circle
@param r2 the radius of the second circle
*/
public CircleComponent( double r1, double r2)
{
String message;

circle1 = new Circle(100, 200, r1);
circle2 = new Circle(200, 100, r2);
Color color;
if (........)
color = Color.GREEN;
else
color = Color.RED;
circle1.setColor(color);
circle2.setColor(color);
}

public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;

circle1.draw(g2);
circle2.draw(g2);
}
}



I think I have the idea of finding distance and compare it with radius, however I don't know what's the right formula for calculating distance cause I haven't touched trig since like 9th grade. Also for the if statement in the tester file, i keep having error with the parameter for the argument.


http://www.purplemath.com/modules/distform.htm

Basically:
+ Show Spoiler +
[image loading]

That image looks like aids...

D = SQUAREROOT( ( x1 - x2)^2 + (y1 - y2 )^2 )

That should hopefully get you started. You can use the java Math library to compute a square root.

*edit* If you're a beginner at programming, my suggestion to you is to NEVER spend two days trying to figure out how to do things. Ask your professors and classmates and TL for help. There is no point banging your head against the wall for two days trying to figure it out yourself. Give it an honest shot. If you can't get it, then just ask for help.

Now if you're an experienced programmer programming DLL injections which uses detours to hook to a function and redirect it to a another program whose responsibility is to send input to another program through windows messages, then you can bang your head against a wall for two days.
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
March 07 2013 02:00 GMT
#5245
On March 07 2013 03:37 JonGalt wrote:
Hey guys, so I am making a website and I want to incorporate a user login system. I am using phpmyadmin, lubuntu 12.10, html 4, and mysql. The problem I am having is that whenever I try to register a user, my browser just downloads register.php instead of adding the user to the database.

I think it has something to do with my apache2 conf files, but I haven't nailed it down.

I edited etc/apache2/mods-available/php5.conf and I created a .htaccess file in the same directory as my index.html where all it has in it is: Type application/x-httpd-php5 .php .phtml

Point is, I am totally lost and would love some insight! I am new to website programming.

Are you using Xampp?

I have no idea what your problem is.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
tuho12345
Profile Blog Joined July 2011
4482 Posts
March 07 2013 02:09 GMT
#5246
On March 07 2013 10:51 Abductedonut wrote:
Show nested quote +
On March 07 2013 10:41 tuho12345 wrote:
Hi everyone, I've been spending the last 2 days try to figure out but I gave up. It looks like a simple homework except I don't know how or where to start. Please help me with this Java problem

here's the question and code
+ Show Spoiler +

Write a graphics program that asks the user to specify the radii of two circles. The first circle has center (100, 200), and the second circle has center (200, 100). Draw the circles. If they intersect, then color both circles green. Otherwise, color them red. Hint: Compute the distance between the centers and compare it to the radii. Your program should draw nothing if the user enters a negative radius. In your exercise, declare a class Circle and a method boolean intersects(Circle other).

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

/**
This class implements a Circle. It includes a method to test whether
two circles intersect.
*/
public class Circle
{
private double xCenter;
private double yCenter;
private double radius;
private Color color;

/**
Constructs a black circle.
@param x the x-coordinate of the center
@param y the y-coordinate of the center
@param r the radius
*/
public Circle(double x, double y, double r)
{
xCenter = x;
yCenter = y;
radius = r;
color = Color.BLACK;
}

/**
Sets the color of this circle.
@param aColor the color
*/
public void setColor(Color aColor)
{
color = aColor;
}

/**
Draws the circles.
@param g2 the graphics context
*/
public void draw(Graphics2D g2)
{
if (radius < 0)
return;

g2.setColor(color);
// draw the circle
Ellipse2D.Double circle
= new Ellipse2D.Double(xCenter - radius, yCenter - radius,
2 * radius, 2 * radius);
g2.draw(circle);
}

/**
Tests whether or not the two circles intersect with each other.
@param other the other circle
@return true the two circles intersect
*/
public boolean intersects(Circle other)
{

double distance;
distance =......
radius = radius + other.radius;
if (distance <= radius)
{
return true;
}
else
{
return false;

}
}
}


tester file

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
Shows two Circles and tests whether they intersect or not.
*/
public class CircleComponent extends JComponent
{
private Circle circle1;
private Circle circle2;


/**
Constructs a component for showing two circles.
@param r1 the radius of the first circle
@param r2 the radius of the second circle
*/
public CircleComponent( double r1, double r2)
{
String message;

circle1 = new Circle(100, 200, r1);
circle2 = new Circle(200, 100, r2);
Color color;
if (........)
color = Color.GREEN;
else
color = Color.RED;
circle1.setColor(color);
circle2.setColor(color);
}

public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;

circle1.draw(g2);
circle2.draw(g2);
}
}



I think I have the idea of finding distance and compare it with radius, however I don't know what's the right formula for calculating distance cause I haven't touched trig since like 9th grade. Also for the if statement in the tester file, i keep having error with the parameter for the argument.


http://www.purplemath.com/modules/distform.htm

Basically:
+ Show Spoiler +
[image loading]

That image looks like aids...

D = SQUAREROOT( ( x1 - x2)^2 + (y1 - y2 )^2 )

That should hopefully get you started. You can use the java Math library to compute a square root.

*edit* If you're a beginner at programming, my suggestion to you is to NEVER spend two days trying to figure out how to do things. Ask your professors and classmates and TL for help. There is no point banging your head against the wall for two days trying to figure it out yourself. Give it an honest shot. If you can't get it, then just ask for help.

Now if you're an experienced programmer programming DLL injections which uses detours to hook to a function and redirect it to a another program whose responsibility is to send input to another program through windows messages, then you can bang your head against a wall for two days.

thanks, I've figured out the distance, now the condition for the tester.

//btw I like to figure shit out lol, I tried to ask friends around but they all afraid of spoiling everything and gave me really ambiguous answer and professor simply never cares about the questions from student, I even tried tutor service at school but a bunch of nerds sat there and no one even cares so fuck it lol
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2013-03-07 02:51:37
March 07 2013 02:50 GMT
#5247
On March 07 2013 11:09 tuho12345 wrote:
Show nested quote +
On March 07 2013 10:51 Abductedonut wrote:
On March 07 2013 10:41 tuho12345 wrote:
Hi everyone, I've been spending the last 2 days try to figure out but I gave up. It looks like a simple homework except I don't know how or where to start. Please help me with this Java problem

here's the question and code
+ Show Spoiler +

Write a graphics program that asks the user to specify the radii of two circles. The first circle has center (100, 200), and the second circle has center (200, 100). Draw the circles. If they intersect, then color both circles green. Otherwise, color them red. Hint: Compute the distance between the centers and compare it to the radii. Your program should draw nothing if the user enters a negative radius. In your exercise, declare a class Circle and a method boolean intersects(Circle other).

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

/**
This class implements a Circle. It includes a method to test whether
two circles intersect.
*/
public class Circle
{
private double xCenter;
private double yCenter;
private double radius;
private Color color;

/**
Constructs a black circle.
@param x the x-coordinate of the center
@param y the y-coordinate of the center
@param r the radius
*/
public Circle(double x, double y, double r)
{
xCenter = x;
yCenter = y;
radius = r;
color = Color.BLACK;
}

/**
Sets the color of this circle.
@param aColor the color
*/
public void setColor(Color aColor)
{
color = aColor;
}

/**
Draws the circles.
@param g2 the graphics context
*/
public void draw(Graphics2D g2)
{
if (radius < 0)
return;

g2.setColor(color);
// draw the circle
Ellipse2D.Double circle
= new Ellipse2D.Double(xCenter - radius, yCenter - radius,
2 * radius, 2 * radius);
g2.draw(circle);
}

/**
Tests whether or not the two circles intersect with each other.
@param other the other circle
@return true the two circles intersect
*/
public boolean intersects(Circle other)
{

double distance;
distance =......
radius = radius + other.radius;
if (distance <= radius)
{
return true;
}
else
{
return false;

}
}
}


tester file

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
Shows two Circles and tests whether they intersect or not.
*/
public class CircleComponent extends JComponent
{
private Circle circle1;
private Circle circle2;


/**
Constructs a component for showing two circles.
@param r1 the radius of the first circle
@param r2 the radius of the second circle
*/
public CircleComponent( double r1, double r2)
{
String message;

circle1 = new Circle(100, 200, r1);
circle2 = new Circle(200, 100, r2);
Color color;
if (........)
color = Color.GREEN;
else
color = Color.RED;
circle1.setColor(color);
circle2.setColor(color);
}

public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;

circle1.draw(g2);
circle2.draw(g2);
}
}



I think I have the idea of finding distance and compare it with radius, however I don't know what's the right formula for calculating distance cause I haven't touched trig since like 9th grade. Also for the if statement in the tester file, i keep having error with the parameter for the argument.


http://www.purplemath.com/modules/distform.htm

Basically:
+ Show Spoiler +
[image loading]

That image looks like aids...

D = SQUAREROOT( ( x1 - x2)^2 + (y1 - y2 )^2 )

That should hopefully get you started. You can use the java Math library to compute a square root.

*edit* If you're a beginner at programming, my suggestion to you is to NEVER spend two days trying to figure out how to do things. Ask your professors and classmates and TL for help. There is no point banging your head against the wall for two days trying to figure it out yourself. Give it an honest shot. If you can't get it, then just ask for help.

Now if you're an experienced programmer programming DLL injections which uses detours to hook to a function and redirect it to a another program whose responsibility is to send input to another program through windows messages, then you can bang your head against a wall for two days.

thanks, I've figured out the distance, now the condition for the tester.

//btw I like to figure shit out lol, I tried to ask friends around but they all afraid of spoiling everything and gave me really ambiguous answer and professor simply never cares about the questions from student, I even tried tutor service at school but a bunch of nerds sat there and no one even cares so fuck it lol


if ( circle1.intersects(circle2) )
color = Color.GREEN;
else
color = Color.RED;

You need to call the intersects function of circle 1 with circle 2 passed in as the object. Depending on whether or not they intersect it will change the color. You've got all the pieces now. You know the distance they're seperated by. How do you figure out whether or not they intersect?
tuho12345
Profile Blog Joined July 2011
4482 Posts
Last Edited: 2013-03-07 03:05:11
March 07 2013 03:02 GMT
#5248
On March 07 2013 11:50 Abductedonut wrote:
Show nested quote +
On March 07 2013 11:09 tuho12345 wrote:
On March 07 2013 10:51 Abductedonut wrote:
On March 07 2013 10:41 tuho12345 wrote:
Hi everyone, I've been spending the last 2 days try to figure out but I gave up. It looks like a simple homework except I don't know how or where to start. Please help me with this Java problem

here's the question and code
+ Show Spoiler +

Write a graphics program that asks the user to specify the radii of two circles. The first circle has center (100, 200), and the second circle has center (200, 100). Draw the circles. If they intersect, then color both circles green. Otherwise, color them red. Hint: Compute the distance between the centers and compare it to the radii. Your program should draw nothing if the user enters a negative radius. In your exercise, declare a class Circle and a method boolean intersects(Circle other).

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

/**
This class implements a Circle. It includes a method to test whether
two circles intersect.
*/
public class Circle
{
private double xCenter;
private double yCenter;
private double radius;
private Color color;

/**
Constructs a black circle.
@param x the x-coordinate of the center
@param y the y-coordinate of the center
@param r the radius
*/
public Circle(double x, double y, double r)
{
xCenter = x;
yCenter = y;
radius = r;
color = Color.BLACK;
}

/**
Sets the color of this circle.
@param aColor the color
*/
public void setColor(Color aColor)
{
color = aColor;
}

/**
Draws the circles.
@param g2 the graphics context
*/
public void draw(Graphics2D g2)
{
if (radius < 0)
return;

g2.setColor(color);
// draw the circle
Ellipse2D.Double circle
= new Ellipse2D.Double(xCenter - radius, yCenter - radius,
2 * radius, 2 * radius);
g2.draw(circle);
}

/**
Tests whether or not the two circles intersect with each other.
@param other the other circle
@return true the two circles intersect
*/
public boolean intersects(Circle other)
{

double distance;
distance =......
radius = radius + other.radius;
if (distance <= radius)
{
return true;
}
else
{
return false;

}
}
}


tester file

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
Shows two Circles and tests whether they intersect or not.
*/
public class CircleComponent extends JComponent
{
private Circle circle1;
private Circle circle2;


/**
Constructs a component for showing two circles.
@param r1 the radius of the first circle
@param r2 the radius of the second circle
*/
public CircleComponent( double r1, double r2)
{
String message;

circle1 = new Circle(100, 200, r1);
circle2 = new Circle(200, 100, r2);
Color color;
if (........)
color = Color.GREEN;
else
color = Color.RED;
circle1.setColor(color);
circle2.setColor(color);
}

public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;

circle1.draw(g2);
circle2.draw(g2);
}
}



I think I have the idea of finding distance and compare it with radius, however I don't know what's the right formula for calculating distance cause I haven't touched trig since like 9th grade. Also for the if statement in the tester file, i keep having error with the parameter for the argument.


http://www.purplemath.com/modules/distform.htm

Basically:
+ Show Spoiler +
[image loading]

That image looks like aids...

D = SQUAREROOT( ( x1 - x2)^2 + (y1 - y2 )^2 )

That should hopefully get you started. You can use the java Math library to compute a square root.

*edit* If you're a beginner at programming, my suggestion to you is to NEVER spend two days trying to figure out how to do things. Ask your professors and classmates and TL for help. There is no point banging your head against the wall for two days trying to figure it out yourself. Give it an honest shot. If you can't get it, then just ask for help.

Now if you're an experienced programmer programming DLL injections which uses detours to hook to a function and redirect it to a another program whose responsibility is to send input to another program through windows messages, then you can bang your head against a wall for two days.

thanks, I've figured out the distance, now the condition for the tester.

//btw I like to figure shit out lol, I tried to ask friends around but they all afraid of spoiling everything and gave me really ambiguous answer and professor simply never cares about the questions from student, I even tried tutor service at school but a bunch of nerds sat there and no one even cares so fuck it lol


if ( circle1.intersects(circle2) )
color = Color.GREEN;
else
color = Color.RED;

You need to call the intersects function of circle 1 with circle 2 passed in as the object. Depending on whether or not they intersect it will change the color. You've got all the pieces now. You know the distance they're seperated by. How do you figure out whether or not they intersect?

in intersects method I need an if statement like this

if (distance <= radius)
{
return true;
}
else
{
return false;

}

the tester file will call up that statement and if it's true - turn green, else - red.

Got it, all work now. Thanks a lot man!:D
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2013-03-07 03:09:49
March 07 2013 03:09 GMT
#5249
On March 07 2013 12:02 tuho12345 wrote:
the tester file will call up that statement and if it's true - turn green, else - red.

Got it, all work now. Thanks a lot man!:D


Yeah, and just as a friendly reminder:

Always put curly braces around single-line statements (trust me, someone will write code there not realizing it's not braced)

Like so:

if ( kitty )
{
doggy();
}


And fix your allman style coding:



if (distance <= radius)
{
return true;
}
else
{
return false;
}


Happy programming.
JonGalt
Profile Joined February 2013
Pootie too good!4331 Posts
March 07 2013 06:54 GMT
#5250
On March 07 2013 04:57 tofucake wrote:
do you have php installed and enabled?


I have php installed. I think I have it enabled, but I am unsure now.

I installed php5, mysql, and phphmyadmin through the terminal the other day. Then I made a dbconfig.php, register.php, login.php, members.php, logout.php, and integrated them with my login.html and register.html.

When I try to register a user through register.html, my browser (chromium) just downloads register.php instead of sending the data to the database. I did many searches and it seemed like I did not have the apache2 conf files correctly configured. After editing what was suggested, I still have the same problem.

And I don't think I have Xammp installed. If you need more information or I am unclear, let me know.
LiquidLegends StaffWho is Jon Galt?
JonGalt
Profile Joined February 2013
Pootie too good!4331 Posts
March 07 2013 07:05 GMT
#5251
On a different note, I feel like even though I graduated with a degree in Computer Science last May at a good university and did well - when I go to program many times I feel lost. I usually can start a program or website or what have you, but then I just get utterly lost and confused halfway through.

I know that a four year degree can not possibly cover everything needed, but sometimes I feel all my degree gave me was a large foundation in which now I am just starting to build upon.

I also have never had a programming internship. I had two internships but neither one involved programming unfortunately.

I guess what I am saying is I feel like I should know more and I don't. I have downloaded many books in all areas of computer programming and am reading those. I am going through the various tuutorials at w3schools, got rid of windows and use linux exclusively, and have tackled various projects (2 website, and one program) to help improve. Is there any other suggestions that you guys have to help me improve more?
LiquidLegends StaffWho is Jon Galt?
Craton
Profile Blog Joined December 2009
United States17274 Posts
March 07 2013 07:16 GMT
#5252
What you're feeling is pretty typical of those in your situation. Your workplace will typically have project/technical managers that will push projects along and deal with the "what do I do now" situation.
twitch.tv/cratonz
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
March 07 2013 07:28 GMT
#5253
On March 07 2013 16:05 JonGalt wrote:
On a different note, I feel like even though I graduated with a degree in Computer Science last May at a good university and did well - when I go to program many times I feel lost. I usually can start a program or website or what have you, but then I just get utterly lost and confused halfway through.

I know that a four year degree can not possibly cover everything needed, but sometimes I feel all my degree gave me was a large foundation in which now I am just starting to build upon.

I also have never had a programming internship. I had two internships but neither one involved programming unfortunately.

I guess what I am saying is I feel like I should know more and I don't. I have downloaded many books in all areas of computer programming and am reading those. I am going through the various tuutorials at w3schools, got rid of windows and use linux exclusively, and have tackled various projects (2 website, and one program) to help improve. Is there any other suggestions that you guys have to help me improve more?

When I first learned how to do Objective-C and iOS development, I started out with a book. I read the whole book straight through, manually typing out all the examples so I could immediately get a feel for the XCode UI and experience with debugging typos. After having finished the entire book and gained a firm understanding of how iOS coding works, when it came time to actually sit down and start my first project, I honestly didn't know what to do. And this is coming from someone who's been developing for quite a while. It took a long time, but eventually I was able to make the mental connections between what I had learned and how I needed to apply it. Now it's second nature. But only because I sat down and actually tried to do something with what I've learned.

I imagine it like a big block of super awesome wizardry in your head. You have the potential to do the magic, but you have to build the mental connections to it and that can only be done with experience. I think if you just keep on going the direction you are, you'll be fine.
JonGalt
Profile Joined February 2013
Pootie too good!4331 Posts
March 07 2013 09:26 GMT
#5254
Thanks a lot!
LiquidLegends StaffWho is Jon Galt?
disco
Profile Blog Joined June 2009
Netherlands1667 Posts
Last Edited: 2013-03-07 09:52:09
March 07 2013 09:50 GMT
#5255
On March 07 2013 15:54 JonGalt wrote:
Show nested quote +
On March 07 2013 04:57 tofucake wrote:
do you have php installed and enabled?


I have php installed. I think I have it enabled, but I am unsure now.

I installed php5, mysql, and phphmyadmin through the terminal the other day. Then I made a dbconfig.php, register.php, login.php, members.php, logout.php, and integrated them with my login.html and register.html.

When I try to register a user through register.html, my browser (chromium) just downloads register.php instead of sending the data to the database. I did many searches and it seemed like I did not have the apache2 conf files correctly configured. After editing what was suggested, I still have the same problem.

And I don't think I have Xammp installed. If you need more information or I am unclear, let me know.


Did you install libapache2-mod-php5 and not just the php cli? (If you want to run php as a apache module that is, which I am assuming you do).

Using a package manager (apt-get) makes your life so much easier. It will automatically update the configuration files for you as well.
this game is a fucking jokie
KainiT
Profile Joined July 2011
Austria392 Posts
March 07 2013 10:02 GMT
#5256
Hey guys, I have a question
I will have have to do a c++ project for university(most likely some b+ tree implementation) which needs to be able to run on Linux
The problem is that I have Windows 7 as my main OS and I don't really want to code using a virtual os, cause the whole thing seems kinda slow,
So would it be a problem to code and test, etc in Windows(probably with Eclipse) and then compile it a final time on Linux after making some hopefully small adjustements? Or would I encounter a massive amount of errors, that are hard to remove? thx for your advice
With great power comes great responsibility.
JonGalt
Profile Joined February 2013
Pootie too good!4331 Posts
March 07 2013 10:30 GMT
#5257
On March 07 2013 19:02 KainiT wrote:
Hey guys, I have a question
I will have have to do a c++ project for university(most likely some b+ tree implementation) which needs to be able to run on Linux
The problem is that I have Windows 7 as my main OS and I don't really want to code using a virtual os, cause the whole thing seems kinda slow,
So would it be a problem to code and test, etc in Windows(probably with Eclipse) and then compile it a final time on Linux after making some hopefully small adjustements? Or would I encounter a massive amount of errors, that are hard to remove? thx for your advice


I had the same issues in university as well.

I always coded in Windows using notepad++ from home. However, I would save all my work on university account using a mapped network drive and a vpn. Then using putty, I could connect to my university's linux computers where my work was saved and run it thought the putty terminal. Win win!
LiquidLegends StaffWho is Jon Galt?
JonGalt
Profile Joined February 2013
Pootie too good!4331 Posts
March 07 2013 10:32 GMT
#5258
On March 07 2013 18:50 disco wrote:
Show nested quote +
On March 07 2013 15:54 JonGalt wrote:
On March 07 2013 04:57 tofucake wrote:
do you have php installed and enabled?


I have php installed. I think I have it enabled, but I am unsure now.

I installed php5, mysql, and phphmyadmin through the terminal the other day. Then I made a dbconfig.php, register.php, login.php, members.php, logout.php, and integrated them with my login.html and register.html.

When I try to register a user through register.html, my browser (chromium) just downloads register.php instead of sending the data to the database. I did many searches and it seemed like I did not have the apache2 conf files correctly configured. After editing what was suggested, I still have the same problem.

And I don't think I have Xammp installed. If you need more information or I am unclear, let me know.


Did you install libapache2-mod-php5 and not just the php cli? (If you want to run php as a apache module that is, which I am assuming you do).

Using a package manager (apt-get) makes your life so much easier. It will automatically update the configuration files for you as well.


I have apt-get, the problem is I don't have internet save for the few times I go to an internet cafe.

I am not sure if I have libapaxhe2-mod-php5 installed. I feel like I only installed the php5 cli, so maybe that is it. I will explore this this weekend. Thanks!
LiquidLegends StaffWho is Jon Galt?
misirlou
Profile Joined June 2010
Portugal3241 Posts
March 07 2013 11:22 GMT
#5259
On March 07 2013 19:02 KainiT wrote:
Hey guys, I have a question
I will have have to do a c++ project for university(most likely some b+ tree implementation) which needs to be able to run on Linux
The problem is that I have Windows 7 as my main OS and I don't really want to code using a virtual os, cause the whole thing seems kinda slow,
So would it be a problem to code and test, etc in Windows(probably with Eclipse) and then compile it a final time on Linux after making some hopefully small adjustements? Or would I encounter a massive amount of errors, that are hard to remove? thx for your advice


If you are using eclipse or other IDE that isn't Visual Studio you will be mostly fine. The only thing you need is compile the code on a Linux Machine after you wrote it and tested it on Windows. However, some libs and commands are Windows or Linux only and you will have to be careful with those.
Ilintar
Profile Joined October 2002
Poland794 Posts
March 07 2013 12:46 GMT
#5260
On March 07 2013 03:37 JonGalt wrote:
Hey guys, so I am making a website and I want to incorporate a user login system. I am using phpmyadmin, lubuntu 12.10, html 4, and mysql. The problem I am having is that whenever I try to register a user, my browser just downloads register.php instead of adding the user to the database.

I think it has something to do with my apache2 conf files, but I haven't nailed it down.

I edited etc/apache2/mods-available/php5.conf and I created a .htaccess file in the same directory as my index.html where all it has in it is: Type application/x-httpd-php5 .php .phtml

Point is, I am totally lost and would love some insight! I am new to website programming.


You almost answered the question yourself.

You have to copy or link php5.conf from mods-available to mods-enabled.
Former webmaster @ WGTour.com / BWLauncher developer
Prev 1 261 262 263 264 265 1032 Next
Please log in or register to reply.
Live Events Refresh
OSC
16:00
OSC Elite Rising Star #17
ForJumy vs MindelVKLIVE!
Shameless vs Percival
SteadfastSC229
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 634
SteadfastSC 229
ProTech124
MindelVK 36
StarCraft: Brood War
Britney 16451
Calm 2765
Shuttle 675
Larva 469
BeSt 245
firebathero 156
Dewaltoss 143
HiyA 17
SilentControl 10
NaDa 8
[ Show more ]
JulyZerg 8
Dota 2
Gorgc6699
Dendi1001
420jenkins279
Counter-Strike
fl0m6117
zeus3368
chrisJcsgo27
kRYSTAL_14
Heroes of the Storm
Khaldor147
Liquid`Hasu4
Other Games
Grubby1800
Beastyqt515
ArmadaUGS109
Sick104
KnowMe98
C9.Mang091
Livibee61
Mew2King60
QueenE60
Trikslyr48
RotterdaM20
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• StrangeGG 41
• Reevou 10
• Kozan
• Migwel
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• FirePhoenix8
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV575
• lizZardDota274
Other Games
• imaqtpie796
• Shiphtur259
Upcoming Events
Replay Cast
4h 38m
Korean StarCraft League
1d 7h
CranKy Ducklings
1d 14h
WardiTV 2025
1d 16h
SC Evo League
1d 17h
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
2 days
WardiTV 2025
2 days
OSC
2 days
[ Show More ]
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
3 days
Wardi Open
3 days
StarCraft2.fi
3 days
Monday Night Weeklies
3 days
Replay Cast
4 days
WardiTV 2025
4 days
StarCraft2.fi
4 days
PiGosaur Monday
5 days
StarCraft2.fi
5 days
Tenacious Turtle Tussle
6 days
The PondCast
6 days
WardiTV 2025
6 days
StarCraft2.fi
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.