-
November 22nd, 2009, 01:42 PM
#1
What is this program asking for
I am very confused as to what this program is asking for me to do...as in, what the user inputs and what i have to output on the screen. Here is the problem straight out of the book. If somebody can clarify what needs to be inputted/outputted then i can get started on the coding but untill then i dont understand what they are asking:
Original Problem:
The type Point is a fairly simple data type, but under another name (the template class pair) this data type is defined and used in the C++ Standard Template Library, although you need not know anything about the Standard Template Library to do this exercise. Write a definition of a class named Point that might be used to store and manipulate the location of a point in the plane. You will need to declare and implement the following member functions:
a.) A member function set that sets the private data after an object of this class is created.
b.) A member function to move the point by an amount along the vertical and horizontal directions specified by the first and second arguments.
c.) A member functions to rotate the point by 90 degrees clockwise around the origin.
d.) Two const inspector functions to retrieve the current coordinates of the point.
Document these functions with appropriate comments. Embed your class in a test program that requests data for several points from the user, creates the points, then exercises the member functions.
-
November 22nd, 2009, 02:08 PM
#2
Re: What is this program asking for
Just implement the member functions...
Code:
class Point {
private:
int x;
int y;
public:
// goal a
void SetX(int x);
void SetY(int y);
// goal b
void Move(int x, int y);
// goal c
// this one is a bit shady
// i would ask for clarification
void RotateClockwise90Degrees();
// goal d
int GetX() const;
int GetY() const;
};
Then...
Document these functions with appropriate comments. Embed your class in a test program that requests data for several points from the user, creates the points, then exercises the member functions.
-
November 22nd, 2009, 02:25 PM
#3
Re: What is this program asking for
so all the member functions are in declared in that class
what about the definition of each function so when i call it from main()
in the main() program, is that were i ask the user to input the numbers/call the the functions and output results? Im kind of new to C++, i just wish i understood the question
also i forgot to mention that my professor told us to change each part of the problem:
a) Replace function "set" with a constructor that creates a point with the given coordinates.
b) Name the function "Displace"
c) Name the function "Rotate90"
d) Name these functions "X" and "Y" (note the capital letters)
Last edited by edbtzy; November 22nd, 2009 at 02:28 PM.
-
November 22nd, 2009, 09:51 PM
#4
Re: What is this program asking for
See this FAQ first.
Did you attempt to write any code? If yes post it here and point where you have problems.
If not what good is it going to do if somebody writes a code for your assignment?
You will have even bigger problem next time and you will not learn anything.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 22nd, 2009, 10:24 PM
#5
Re: What is this program asking for
Originally Posted by JohnCz
You will have even bigger problem next time and you will not learn anything.
Is that what you know or predict ?
-
November 22nd, 2009, 10:35 PM
#6
Re: What is this program asking for
Originally Posted by DMNX
Is that what you know or predict ?
What difference does it make?
It is a simple conclusion: you do not learn basics, you won’t be able to understand advanced.
Funny thing: some people pay for getting educated and then refuse to learn.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 22nd, 2009, 10:46 PM
#7
Re: What is this program asking for
It's a fighting, not learning process, I am quite low anyway, sorry for my intervention I know nothing what you guys are digusting about but consulting and advertising seem to be the point here
-
November 22nd, 2009, 11:11 PM
#8
Re: What is this program asking for
bump....I'm in the same course, any help on what this program is asking for would be greatly appreciated. not the answer, I will happily code through the day, I just cant figure out what they want me to do...
-
November 22nd, 2009, 11:23 PM
#9
Re: What is this program asking for
No need for the smart remarks i actually did do code myself and i have it here to prove it:
#include <iostream>
#include "Point.h"
using namespace std;
int main ()
{
int xvalue, xchange;
int yvalue, ychange;
cout<<"Enter X value: ";
cin>>xvalue;
cout<<"Enter Y value: ";
cin>>yvalue;
Point p1(xvalue, yvalue);
cout<<"Horizontal: ";
cin>>xchange;
cout<<"Vertical: ";
cin>>ychange;
p1.Displace(xchange, ychange);
return 0;
}
Point::Point(int xval, int yval)
{
x=xval;
y=yval;
}
void Point:isplace(int xval, int yval)
{
xval=+x;
yval=+x;
}
int Point::X()
{
return x;
}
int Point::Y()
{
return y;
}
-
November 22nd, 2009, 11:26 PM
#10
Re: What is this program asking for
Originally Posted by JohnCz
What difference does it make?
It is a simple conclusion: you do not learn basics, you won’t be able to understand advanced.
Funny thing: some people pay for getting educated and then refuse to learn.
the funny thing is that people pay to get educated but there professor sucks at learning so we try to come here to get advice and people like you surely doesn't help...so keep your comments to yourself
-
November 23rd, 2009, 01:22 AM
#11
Re: What is this program asking for
Originally Posted by edbtzy
the funny thing is that people pay to get educated but there professor sucks
Maybe it isn't the professor. Maybe its the student who thinks that learning programming can be done by doing 10 minutes of work, and then gets frustrated when they find out that programming isn't a "cram at the last hour" subject, or one where you can only spend 10 minutes on.
people like you surely doesn't help...so keep your comments to yourself
Funny how newbies want to dictate how experienced forum participants should behave. John Cz has over 9,000 posts -- you have 8 posts. So who do you think has helped more people here?
You initially didn't post any code. Why didn't you post the code the first time? Why did it take one of us "who should keep our comments to ourselves" to make you show your code?
Next time, put the code in code tags. And lastly as it stands now, what is your specific question concerning this assignment? Or is this resolved?
Regards,
Paul McKenzie
-
November 23rd, 2009, 02:55 AM
#12
Re: What is this program asking for
first off the teacher i have is known to be horrible at teaching c++ and i have taken other c++ courses in the past and have done well in it . But i always had trouble with these kind of problems. I know how coding takes time, i never asked for any1 to the code for me, i just gave them the problem so they can explain what needs to be done. Every forum you try to go to to get help, there is always that one person that has to bash the OP. But no worries, i got the code all written out and did it myself.
Last edited by edbtzy; November 23rd, 2009 at 03:00 AM.
-
November 23rd, 2009, 05:26 AM
#13
Re: What is this program asking for
Originally Posted by edbtzy
first off the teacher i have is known to be horrible at teaching c++
Maybe, maybe not. It could be that the teacher is looking for those students who can work independently with little help -- the reason is that this is the way it is in the real world of programming. Many, if not most teachers of programming teach this way, as it is used to weed out the ones who just won't be able to handle the subject matter. For the mercy of the student, this technique is used to silently direct the student to drop the course (or change majors).
Also, I bet that there are students who do understand the work and are handing in the assignments on time. Whether it's 1, 2, or 3 students out of 20 or 25, that is about the average number of students who have a good chance of being programmers. Programming is not going to be mastered by 50% or more of the class -- it just doesn't work that way, unlike other subjects.
Every forum you try to go to to get help, there is always that one person that has to bash the OP.
The proper way to ask questions is to not just post your assignment verbatim without any code whatsoever. That will tick off a lot of people here, because it gives the impression that you do not want to do the work, and the people that are going to help you have worked hard to get where they are.
Regards,
Paul McKenzie
-
November 23rd, 2009, 12:19 PM
#14
Re: What is this program asking for
I'll remember that next time. Thanks again
-
November 23rd, 2009, 12:55 PM
#15
Re: What is this program asking for
Originally Posted by edbtzy
first off the teacher i have is known to be horrible at teaching c++
This is maybe true but it also can be misconception. You hear a gossip and automatically take it at the face value.
You are a college student and it is assumed that you do not need guidance in your learning process.
If you tried to ask a teacher specific questions to explain areas that are difficult to understand, you most likely would get answers. If first explanation you are getting is not enough, ask more and more questions until your problem is resolved. There is no such a thing as stupid question.
If you have problem getting answers after being persistent, you can bring that to the attention of proper authorities including dean.
Again, you are paying to get educated; hence, you have a right to request quality.
In my 18 years of acquiring school education, I had only one problem with a teacher in high school. He was just one bad apple in an army of people that educated me.
Another think you have to be able to acquire knowledge. If you are planning to be a programmer, it will be continuing process of educating yourself to keep up with rapid advance of technology.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|