Click here to Skip to main content
15,895,011 members
Home / Discussions / Java
   

Java

 
GeneralRe: help: equals() method to compare the attributes Pin
mastdesi7-Oct-11 8:52
mastdesi7-Oct-11 8:52 
AnswerRe: help: equals() method to compare the attributes Pin
Nagy Vilmos6-Oct-11 22:43
professionalNagy Vilmos6-Oct-11 22:43 
GeneralRe: help: equals() method to compare the attributes Pin
mastdesi7-Oct-11 5:17
mastdesi7-Oct-11 5:17 
GeneralRe: help: equals() method to compare the attributes Pin
Nagy Vilmos7-Oct-11 7:14
professionalNagy Vilmos7-Oct-11 7:14 
QuestionPlease help with java assignment Pin
mastdesi6-Oct-11 4:43
mastdesi6-Oct-11 4:43 
AnswerRe: Please help with java assignment Pin
Nagy Vilmos6-Oct-11 5:46
professionalNagy Vilmos6-Oct-11 5:46 
GeneralRe: Please help with java assignment Pin
mastdesi6-Oct-11 6:19
mastdesi6-Oct-11 6:19 
GeneralRe: Please help with java assignment Pin
TorstenH.6-Oct-11 19:44
TorstenH.6-Oct-11 19:44 
what a mess - where to start?

Java
poly[0] = new Polynomial(tmp[0], tmp[1], tmp[2], tmp[3], tmp[4]);

that's evil. Please use:
Java
poly[0] = new Polynomial(tmp);

and create a constructor
Java
// Constructor with 5 parameter 
public Polynomial(int[] values) {
	this.coeff = values;
}


than there is a neat chance for a loop as your code does several times the same thing:
Java
// Values for Polynomial 0
8System.out.println("Enter a polynomial");
for(int i=0; i<5;i++) 
{
	System.out.print("Coefficient for X^" + i + ": ");
	int coeff = input.nextInt();
	tmp[i] = coeff;
}
poly[0] = new Polynomial(tmp);
// ...
// the same stuff 4 more times for poly[1] - poly[4]
// ...

This looks much better when done in a loop:

Java
for(int iCount=0; iCount<=poly.length; iCount++){
	for(int i=0; i<5;i++) {
	    System.out.print("Coefficient for X" + i + ":");
	    int coeff = input.nextInt();
	    tmp[i] = coeff;
	}
	poly[iCount] = new Polynomial(tmp);
}

regards Torsten
I never finish anyth...

GeneralRe: Please help with java assignment Pin
Nagy Vilmos6-Oct-11 23:31
professionalNagy Vilmos6-Oct-11 23:31 
GeneralRe: Please help with java assignment Pin
mastdesi6-Oct-11 6:33
mastdesi6-Oct-11 6:33 
GeneralRe: Please help with java assignment Pin
Nagy Vilmos6-Oct-11 23:58
professionalNagy Vilmos6-Oct-11 23:58 
AnswerRe: Please help with java assignment Pin
I.explore.code12-Oct-11 4:31
I.explore.code12-Oct-11 4:31 
QuestionMultilevelqueue Pin
jhencer1111085-Oct-11 12:40
jhencer1111085-Oct-11 12:40 
AnswerRe: Multilevelqueue Pin
Richard MacCutchan5-Oct-11 21:49
mveRichard MacCutchan5-Oct-11 21:49 
AnswerRe: Multilevelqueue Pin
Nagy Vilmos5-Oct-11 22:35
professionalNagy Vilmos5-Oct-11 22:35 
QuestionTroubble with "new" Pin
Tor Danielsen4-Oct-11 11:00
Tor Danielsen4-Oct-11 11:00 
AnswerRe: Troubble with "new" Pin
DaveAuld4-Oct-11 12:03
professionalDaveAuld4-Oct-11 12:03 
GeneralRe: Troubble with "new" Pin
Tor Danielsen4-Oct-11 12:28
Tor Danielsen4-Oct-11 12:28 
GeneralRe: Troubble with "new" Pin
DaveAuld4-Oct-11 13:37
professionalDaveAuld4-Oct-11 13:37 
AnswerRe: Troubble with "new" Pin
Luc Pattyn4-Oct-11 13:40
sitebuilderLuc Pattyn4-Oct-11 13:40 
AnswerRe: Troubble with "new" Pin
Nagy Vilmos4-Oct-11 21:47
professionalNagy Vilmos4-Oct-11 21:47 
AnswerRe: Troubble with "new" Pin
Richard MacCutchan4-Oct-11 21:50
mveRichard MacCutchan4-Oct-11 21:50 
AnswerRe: Troubble with "new" Pin
TorstenH.4-Oct-11 23:57
TorstenH.4-Oct-11 23:57 
GeneralRe: Troubble with "new" Pin
Nagy Vilmos5-Oct-11 0:12
professionalNagy Vilmos5-Oct-11 0:12 
GeneralRe: Troubble with "new" Pin
Richard MacCutchan5-Oct-11 0:20
mveRichard MacCutchan5-Oct-11 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.