G:\Documents and Settings\ben\Desktop\Desktop\Desktop\Ben\park>javac HultinBenPr
og7.java
HultinBenProg7.java:20: cannot find symbol
symbol : constructor Fraction()
location: class Fraction
x = new Fraction(); // create a fraction for number 0
^
HultinBenProg7.java:23: add() in Fraction cannot be applied to (Fraction)
x.add(c).add(d);
^
HultinBenProg7.java:30: multiply() in Fraction cannot be applied to (Fraction)
x.multiply(c).multiply(d);
^
3 errors
When you do things right, people won't be sure you've done anything at all.
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
HultinBenProg7.java:20: cannot find symbol
symbol : constructor Fraction()
location: class Fraction
x = new Fraction(); // create a fraction for number 0
HultinBenProg7.java:23: add() in Fraction cannot be applied to (Fraction)
x.add(c).add(d);
^
HultinBenProg7.java:30: multiply() in Fraction cannot be applied to (Fraction)
x.multiply(c).multiply(d);
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
HultinBenProg7.java:23: add(int,int) in Fraction cannot be applied to (Fraction)
x.add(c).add(d);
^
HultinBenProg7.java:30: multiply(int,int) in Fraction cannot be applied to (Frac
tion)
x.multiply(c).multiply(d);
^
2 errors
G:\Documents and Settings\ben\Desktop\Desktop\Desktop\Ben\park>
Ben Hultin wrote:well I tried the suggestion you made and it didnt seem to help, I still get the same errors.
the compiler is complaining about not being able to use add(int,int), would the add and multiply method need to have string parameters seeing as the values are coming from objects? Just a thought.
Thanks a lot for your help
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Ben Hultin wrote:well as for the code:
That was given by the proffessor as to make it work with my driven class and its methods within.
I read the article you mentioned and some other ones as well, that may help, but I culdnt find one that covered this particular problem of referencing an objects parameter, not arguments which is what their examples showed.
what I getting from the code so far, is that the teacher is trying to add first c to x, then add d to x as well.
I am sure this was rather obvious, but I find the long hand version helps to reduce confusion as to the purpose of the code.
c is holding two ints inside of it, so is d. So I figure the add() and multiply() methods would working with two ints found inside of each object individually then assign the result to x, which will be printed.
That is what I believe, I may be very wrong about this.
I appreciate the help in the matter
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Ben Hultin wrote:So to get the method signature to accept objects and not ints that would be something like this?
or would it be something like this?
I dont see why the second would work seeing as the object is holding ints and not Strings.
I appreciate the help
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
HultinBenProg7.java:23: int cannot be dereferenced
x.add(c).add(d);
^
HultinBenProg7.java:30: int cannot be dereferenced
x.multiply(c).multiply(d);
^
2 errors
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
.\Fraction.java:37: missing return statement
}
^
.\Fraction.java:47: missing return statement
}
^
2 errors
// second compile
G:\Documents and Settings\ben\Desktop\Desktop\Desktop\Ben\park>javac HultinBenPr
og7.java
.\Fraction.java:35: incompatible types
found : void
required: int
return System.out.println(this.numerator + " / " + this.denomina
tor);
^
.\Fraction.java:43: incompatible types
found : void
required: int
return System.out.println(this.quotient);
^
2 errors
G:\Documents and Settings\ben\Desktop\Desktop\Desktop\Ben\park>
When you do things right, people won't be sure you've done anything at all.
When you do things right, people won't be sure you've done anything at all.
Ben Hultin wrote:Are you refering to something like this? I made it a double bc quotient is a double type thats being returned, is that correct?
Ben Hultin wrote:
The other question I have is once I have the value assigned to quotient... how would I assign that value to object x in my driver class from this driven class method?
Thanks a lot for the help
When you do things right, people won't be sure you've done anything at all.
I'm full of tinier men! And a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|