Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.224.52.54
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/point.cpp
//
//	File:	point.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 Pixel : public Point
{	StatusType status;
public:
	Pixel()	// (0, 0) OFF
	{	status = OFF;	}
	Pixel( int a, int b, StatusType s)
	: Point(a, b)
	{	status = s;	}
};


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