Accessibility errors

Ok Same project new problem.
My assignment has me using a bunch of pre-written code and I just need to fill in the blanks. Now after following the instructions thus far I'm running into an accessibility error.
Here's the instructions I am provided:

There is a green dot that translates across the screen. Study Point3D.cpp.

#include <math.h>

#include "Point3D.h"
#include "GraphicsLib.h"

Point3D::Point3D( void ) //defining the default constructor from the Point3D class in //Points3D.h. Note the scope resolution operator :: is used to refer to the class Point3D

{
x = y = z = 0.0f ;
}

Point3D::Point3D( float x, float y, float z ) //defining the constructor w/ 3 parameters
{
this->x = x ; //using the this pointer to access the member data x
this->y = y ;
this->z = z ;
}

Point3D::~Point3D(void) //destructor
{
}

double Point3D::Distance(const Point3D & other ) const //defining the Distance function
{
double result = 0.0 ;

double delta[3] ;
delta[0] = x - other.x ;
delta[1] = y - other.y ;
delta[2] = z - other.z ;

result = sqrt( delta[0]*delta[0] + delta[1]*delta[1] + delta[2]*delta[2] ) ;

return result ;
}

void Point3D::Render( const Appearance* appearance ) const //defining Render function
{
byte r, g, b ;
appearance->Get_RGB( r, g, b ) ;
DrawingSurface::Draw_Point( ROUND( x ), ROUND( y ), r, g, b ) ; // round
//coordinates to nearest integer
}

void Point3D::Translate(double Tx, double Ty, double Tz) //defining translate function
{
x += float( Tx ) ;
y += float( Ty ) ;
z += float( Tz ) ;
}

Then I'm given this code for a sphere:

Sphere::Sphere(void)
{
radius = 0.0f ;
}

Sphere::~Sphere(void)
{
}

Add this definition of the constructor with two parameters, consisting of center and radius:
Sphere:: Sphere( Point3D& center, float radius )
{
Fill-in the appropriate two lines of code that go here. For an idea, see the structure of the similar constructor in Point3D.cpp, the one having 3 parameters.
}

Then translate the center:
void Sphere:: Translate( double Tx, double Ty, double Tz )
{
Write the appropriate one line of code to translate the center (Tx,Ty,Tz) using the Translate method.
}

Finally, render the sphere:
void Sphere::Render( const Appearance* appearance ) const
{
See Point3D.cpp for the two lines of code that you will need here.

Then use the Draw_Circle method:
DrawingSurface::Draw_Circle( int( center.x+0.5f ),write the appropriate code here,
int( radius+0.5f ), appearance->solid, r, g, b ) ;
}
The sphere should now render and translate.

I've gotten down to adding code to the Draw_Circle method and when I try to enter the parameters VS is telling me that x and y are attributes of Point3D.center and are inaccessible as they are private data members. Is ther something I'm doing wrong or is this code bogus?
Last edited on
Your sphere looks like it's represented by a center point and a radius.

So if you want to move the sphere... just move the center point.
I know I need to move the center, but in Point3D.cpp the x,y, and z coordinates are applied to the x,y, and z position of the green dot by coding x+=Tx etc. How to I apply Sphere::Translate(double, double, double) to the center of the sphere?
There are 3 coordinates and only 1 center.
Last edited on
Maybe I'm not understanding the question......

If you move the center point... the entire sphere moves because a sphere's position is determined by its center.

So all you have to do to move the sphere is move the center point.

You already have a function (Point3D::Translate) which moves a single point.

So just call that routine to move the center point.
There is only ONE center and THREE coordinates. How do I apply those coordinates to the center? Point3D::Translate applies 3 changes to 3 attributes. There is only one center

void Sphere::Translate(double Tx, double Ty, double Tz)
{
center=Point3D::Translate;
}

gives me an error
Last edited on
There is only ONE center and THREE coordinates. How do I apply those coordinates to the center?


You pass them as parameters to the Translate function. Notice how Point3D's translate function takes 3 coordinates.

center=Point3D::Translate;

gives me an error


Yes it would, because it's nonsense. Did you learn how to call functions? Specifically member functions?

 
object.function_name(  parameters  );


Here, the object you want to modify is the center point
The function you want to call is Translate
and the parameters are the 3 coords.
I know how to call member functions I mistyped the code. Look, I don't learn very well when it comes to reading the information. I need to see it done first then I reverse engineer the solution until I understand it. Basically what I need is the solution ONE time and an explanation for each step. Then I can apply to similar problems from then on.

void Sphere::Translate(double Tx, double Ty, double Tz)
{
center=Point3D.Translate(Tx, Ty, Tz);
}

?

I don't know how to make this work. I don't know what parameters to pass. None of this seems clear
@KryptonianJedi

There is only ONE center and THREE coordinates. How do I apply those coordinates to the center?


Thank you. I have laughed.:)

center is a 3D point (of type Point3D) so it also has THREE coordinates.:)
Ok I see now that center is actually a Point3D object. Did not make that connection since most of the code was provided for me and I am only adding the lines of code required by the assignment. I'm still confused on how I'm supposed to apply the Point3D::Translate to Sphere::Translate. I am a true novice taking 8 week cramfest courses and then just slowly relearning everything I crammed to pass my lasses to little programming projects of my own. I need a lot of help and detailed explanation as I am in way over my head. It doesn't make my student debt any less real or my need for this knowledge any less necessary. Glad I could make you laugh. Now how about some more help ;)
1
2
3
4
void Sphere::Translate(double Tx, double Ty, double Tz)
{
   center,Translate( Tx, Ty, Tz );
}
LMAO. As I was looking at typing my reply and looking at your first one it all started to make sense. SATORI! Thank you to all who replied.
Last edited on
Ok Same project new problem.
My assignment has me using a bunch of pre-written code and I just need to fill in the blanks. Now after following the instructions thus far I'm running into an accessibility error.
Here's the instructions I am provided:

There is a green dot that translates across the screen. Study Point3D.cpp.

#include <math.h>

#include "Point3D.h"
#include "GraphicsLib.h"

Point3D::Point3D( void ) //defining the default constructor from the Point3D class in //Points3D.h. Note the scope resolution operator :: is used to refer to the class Point3D

{
x = y = z = 0.0f ;
}

Point3D::Point3D( float x, float y, float z ) //defining the constructor w/ 3 parameters
{
this->x = x ; //using the this pointer to access the member data x
this->y = y ;
this->z = z ;
}

Point3D::~Point3D(void) //destructor
{
}

double Point3D::Distance(const Point3D & other ) const //defining the Distance function
{
double result = 0.0 ;

double delta[3] ;
delta[0] = x - other.x ;
delta[1] = y - other.y ;
delta[2] = z - other.z ;

result = sqrt( delta[0]*delta[0] + delta[1]*delta[1] + delta[2]*delta[2] ) ;

return result ;
}

void Point3D::Render( const Appearance* appearance ) const //defining Render function
{
byte r, g, b ;
appearance->Get_RGB( r, g, b ) ;
DrawingSurface::Draw_Point( ROUND( x ), ROUND( y ), r, g, b ) ; // round
//coordinates to nearest integer
}

void Point3D::Translate(double Tx, double Ty, double Tz) //defining translate function
{
x += float( Tx ) ;
y += float( Ty ) ;
z += float( Tz ) ;
}

Then I'm given this code for a sphere:

Sphere::Sphere(void)
{
radius = 0.0f ;
}

Sphere::~Sphere(void)
{
}

Add this definition of the constructor with two parameters, consisting of center and radius:
Sphere:: Sphere( Point3D& center, float radius )
{
Fill-in the appropriate two lines of code that go here. For an idea, see the structure of the similar constructor in Point3D.cpp, the one having 3 parameters.
}

Then translate the center:
void Sphere:: Translate( double Tx, double Ty, double Tz )
{
Write the appropriate one line of code to translate the center (Tx,Ty,Tz) using the Translate method.
}

Finally, render the sphere:
void Sphere::Render( const Appearance* appearance ) const
{
See Point3D.cpp for the two lines of code that you will need here.

Then use the Draw_Circle method:
DrawingSurface::Draw_Circle( int( center.x+0.5f ),write the appropriate code here,
int( radius+0.5f ), appearance->solid, r, g, b ) ;
}
The sphere should now render and translate.

I've gotten down to adding code to the Draw_Circle method and when I try to enter the parameters VS is telling me that x and y are attributes of Point3D.center and are inaccessible as they are private data members. Is ther something I'm doing wrong or is this code bogus? I added the same post to the bottom here since I'm reviving an old post involving the same assignment, but with a new issue.
Last edited on
For future posts, please put your code in code tags as it makes it much easier to read and retains whitespace:

[code]
Put your code between these
[/code]

Anyway... as for your problem... is there a GetX() or any kind of similar function in Point3D? Maybe you're supposed to use that instead of accessing the x member directly.
No there isn't, but maybe there's an issue w/ my Sphere constructors. Here's the code that I have in VS right now.
Point3D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <math.h>

#include "Point3D.h"
#include "GraphicsLib.h"

Point3D::Point3D( void )
{
	x = y = z = 0.0f ;
}

Point3D::Point3D( float x, float y, float z )
{
	this->x = x ;
	this->y = y ;
	this->z = z ;
}

Point3D::~Point3D(void)
{
}

double Point3D::Distance(const Point3D & other ) const
{
	double result = 0.0 ;

	double delta[3] ;
	delta[0] = x - other.x ;
	delta[1] = y - other.y ;
	delta[2] = z - other.z ;

	result = sqrt( delta[0]*delta[0] + delta[1]*delta[1] + delta[2]*delta[2] ) ;

	return result ;
}

void Point3D::Render( const Appearance* appearance ) const
{
	byte r, g, b ;
	appearance->Get_RGB( r, g, b ) ;
	DrawingSurface::Draw_Point( ROUND( x ), ROUND( y ), r, g, b ) ; // round coordinates to nearest integer
}

void Point3D::Translate(double Tx, double Ty, double Tz)
{
	x += float( Tx ) ;
	y += float( Ty ) ;
	z += float( Tz ) ;
}


and here is Sphere.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <math.h>

#include "Sphere.h"
#include "GraphicsLib.h"

Sphere::Sphere(void)
{
	radius=0.0f;
}

Sphere::~Sphere(void)
{
}

Sphere::Sphere(Point3D& center, float radius)
{
	this->center=center;
	this-> radius=radius;
}

 void Sphere::Translate(double Tx, double Ty, double Tz)
{
	center.Translate(Tx, Ty, Tz);
}

 void Sphere::Render(const Appearance* appearance) const
 {
	byte r, g, b;
	appearance->Get_RGB(r, g, b);

	DrawingSurface::Draw_Circle(int(center.x+0.5f), int(center.y+0.5f),int (radius+0.5f), appearance-> solid, r,  g, b);
 }


there's no Get() method in 3DPoints.cpp, but like I said I wonder If my Sphere parameterized constructor is wonky. Thanks!
helpful discussion.... i need this type of info.... So thanks a lots
Topic archived. No new replies allowed.