0

So I have designed my program but am stuck on one function.
The following is an excerpt from my class:

public class SqrXY
{
    public void SqrXY (double x, double y)
    {
        xaxis = x;
        yaxis = y;
    }
    public double addition ()
    {
        //this is what I am stuck on
    }
}

And excerpt from my run class:

SqrXY instance1 = new SqrXY (4.0, 2.0);
SqrXY instance2 = new SqrXY (6.0, 3.0);
SqrXY instance3 = instance1.addition(instance2); //instance3 is initialized as (10.0, 5.0)

So I need to create an addition function which will add the values of the already initialized objects. This is the last part of my assignment and I've been stuck on it for a couple days any help would be appreciated.

Edited by solitaryy: n/a

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by solitaryy
0

Wouldn't something like this work?

sqrXY instance3 = new sqrXY(instance1.xaxis+instance2.xaxis, instance1.yaxis+instance2.yaxis);

I'm just guessing here by the way, I'm a student myself...

0

But I have to make a function named addition to go in the SqrXY class this doesn't do that.

SqrXY instance3 = instance1.addition(instance2);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.