List Info

Thread: C-Sharp (C#) Group: Comparable Help




C-Sharp (C#) Group: Comparable Help
country flaguser name
United States
2007-05-31 15:43:46
Hey there,

If I have a class Point that holds an x and y coordinate.

How do I implement a comparable class so that for example:

Point a,b;
if (a < b)
{
....
}

Here is I have so far:

public class Point
{
    private double x;
    private double y;
    public double X
    {
        get
        {
            return this.x;
        }
        set
        {
            this.x = value;
        }
    }
    public double Y
    {
        get
        {
            return this.y;
        }
        set
        {
            this.y = value;
        }
    }

Thanks!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://g
roups.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---


C-Sharp (C#) Group: Re: Comparable Help
country flaguser name
United States
2007-05-31 17:03:05
What do you mean by a < b? On any given plane what point
is greatest?  If so
where are you starting from? Top Left, Top Right, Bottom
Left, Bottom Right,
or an abstract point?  If not abstract pick your starting
point.  Then
incrementally assign x,y coordinates a unique number value;
store this value
and the x y cords for each point in a hash table or an array
list that is
exposed or is a member of your class.  Wright a static
method in your point
class, passing the x and y of each a and b (or any other two
points, lookup
the number values in your hash table for each point, then
pass back the
result--either greater or smaller.

Hope this helps,


Jeremy Schreckhise, M.B.A.


-----Original Message-----
From: C_Sharpgooglegroups.com [mailto:C_Sharpgooglegroups.com] On Behalf
Of jobo
Sent: Thursday, May 31, 2007 3:44 PM
To: C-Sharp (C#)
Subject: C-Sharp (C#) Group: Comparable Help


Hey there,

If I have a class Point that holds an x and y coordinate.

How do I implement a comparable class so that for example:

Point a,b;
if (a < b)
{
....
}

Here is I have so far:

public class Point
{
    private double x;
    private double y;
    public double X
    {
        get
        {
            return this.x;
        }
        set
        {
            this.x = value;
        }
    }
    public double Y
    {
        get
        {
            return this.y;
        }
        set
        {
            this.y = value;
        }
    }

Thanks!




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://g
roups.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )