Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.85.74
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/kmmowery/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/kmmowery/line.cpp
//
//	File:	line.cpp
//	p.167
//
//	Define a Point class that illustrate 
//	a point at coordinates
//


#include <iostream>
#include <iomanip>	// for setprecision

using namespace std;

class Point
{	// data
private:
	int x, y;
public:
	// constructors
	Point ()
	{	x = y = 0;	}
	Point (int a, int b)
	{	x = a;
		y = b;
	}
	// p.168
	float Distance (Point p) const
	{	float d;
		int x0, y0;
		x0 = x - p.x;
		y0 = y - p.y;
		d = sqrt(1.0*x0*x0 + y0*y0);
		return d;
	}
};

// define a subclass of Point, named Pixel, p.167

enum StatusType {ON, OFF};

class Line 
{	// two data;
	Point startP, endP;
public:
	Line ( int startX, int startY, int endX, int endY)
	: startP (sx, yY ) , endP (ex, ey)
	{	}
	float Length() const;
	{	return = startP.distance(;	}
};


int main()
{       // p.168 #2
        Pixel onePixel (1, 1, ON);
        Pixel origin;                   // (0, 0) OFF

	cout << fixed << showpoint << setprecision(1);

        // #3
        cout << "The dis from origin to onePixel: "
                << onePixel.Distance(origin);


	cout << "\n\nDone.\n\n";
	return 0;
} 
	


Stv3n404 - 2023