# Thread: NEED HELP Please!!!

1. Member
Join Date
May 2010
Posts
6
Rep Power
0

## NEED HELP Please!!!

Hey guys, i have been working on this code for 2 days. I was wondering if someone can help me out, ITS DUE TOMORROW!!

This is the question/prompt:
Build the class LINE of equation y=ax+b.
Their attributes a and b are integers.
Two contructors are created: one with both a and b are provided,and the other only a is provided (in the second case, set b=0)
One method is built: printLINE: if (b==0) print equation of form y=ax else print equation of form y=ax+b.

In the test section, build 2 objects: abc=new LINE(2,3) and xyz=new LINE(5). Then print oth both of them. You expect the first object will be y=2x+3 and the second y=5x

This is what i have so far and it outputs y=0x (2 times):
//Monish Mehta
//04-30-2010
//Build a line y=ax+b
class LINE {

//attribute
int a;
int b;

//constructor
LINE (int a, int b){
}
LINE (int a){
b= 0;
}
//method
public void printLine (){
if (b==0)
System.out.println ("y="+a+"x");
else
System.out.println ("y="+a+"x"+"+"+b);
}
//Test
public static void main(String[] args){
LINE abc= new LINE (2,3);
LINE xyz= new LINE (5);
abc.printLine ();
xyz.printLine ();

}
}

PLEASE HELP! :confused:
THANKS IN ADVANCE

2. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
7
Originally Posted by mmonish91
Hey guys, i have been working on this code for 2 days. I was wondering if someone can help me out, ITS DUE TOMORROW!!
This is not our problem, and though it may be surprising to you, it makes us less likely to want to help you. Also, use CODE tags and format your code properly if you want people to try to read it.

The problem is in your first constructor. It doesn't do anything, and it needs to.

-Gary-

3. Originally Posted by gcalvin
This is not our problem, and though it may be surprising to you, it makes us less likely to want to help you.
Agree. It suggests that you feel that your question is more important than everyone else's and that you want to rush and pressure others to help you. No one likes to be pressured to do anything, least of all the volunteers who help out on this forum. Much luck.

4. Member
Join Date
May 2010
Posts
6
Rep Power
0
Hey guys i am really sorry. That was not my intention. It's just that i am a first time forum user. I have never used it before.
Sorry Once again. What do you suggest i should do?

5. As Gary stated, your constructors take parameters but don't do anything with them. You should use the constructor parameters to set class fields (you have two of them, ints a and b).

If you make the changes but it still doesn't work out, (as Gary stated), please post well-formatted code using code tags (see my signature below for more on how to use code tags).

Much luck.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•