Programming by using oops concept [closed] - oop

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
can you give me a idea about the following program:
There is vehicle factory. The common attribute of all the vehicles are that they can run. Building the basic structure of any vehicle, it is required to pass wheel count, wheel size and factor. The max speed is defined by the multiplication of wheel count, size and factor.
The factory can build: Cycle, MotorCycle, Car, Bus.
When those vehicle run they print <Vehicle Name>can run at speed<Max Speed>
Please write a program using OO approach.
Factor:Cycle=1,MotorCycle=2,Car=4,Bus=6
Wheel Size:Cycle=10, MotorCycle=12, Car=12, Bus=20
What is the best way to do this?

Read between the lines:
They can run: refers to a method.
Building the basic structure: refers to a constructor, in fact it sums up the constructor parameters.
The max speed is defined by the multiplication of ...: a calculated property.
The factory can build ... sums up the subtypes of Vehicle. (As you already understood).
When those vehicle run they ... : tells you what the run method should do.
Then the constructor parameters are given, assuming you can figure out the wheel count.

Related

why do you have to write interface and implementation in objective C instead just implementation [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I would like to know, why is so important to write interface and implementation for every calss in Objective C. In other langauge this technique is only optional.
In Objective-C, writing an interface is also optional (so is declaring methods), although the compiler will likely warn you. Writing the interface permits somebody else to reuse the binary form of your code without having to recompile it; this way you can also hide the implementation details/the code from the one who reuses your class. Also, if only you use your own class, the compiler may need some information at compile time (although Objective-C is a dynamic language) about the classes you write -- in this case you can't include the whole implementation file as it would result in duplicating your entire class, redulting in a linker error. Same reason why there are header files for any C library out there.
Interface describes how other classes and their instances will interact with your class and its instances. You could just create implementation, but that would kind of defeat the purpose of OOP.

Get coordinates of head in Kinect [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
i am making an App in Open GL (C++) with Kinect.
I want to get the coordinates of head (Skeleton).
I saw the function:
void CSkeletalViewerApp::Nui_DrawSkeletonSegment( NUI_SKELETON_DATA * pSkel, int numJoints, ... ) ,
but I dont know how to use it and extract the coordinates of the head.
Judging from the code snipped you posted, we can assume you are using Microsoft's Kinect for Windows SDK.
The coordinates of the joints are stored in the SkeletonPositions member of the NUI_SKELETON_DATA structure. Instances of this structure can be found in the SkeletonData member of the NUI_SKELETON_FRAME structure, which is provided whenever the skeleton tracking engine finishes tracking.
Of course, this will only work, if the sensor is initialized properly. Please have a look at the sample projects that come with the SDK, and read Microsoft's online documentation.
Also, be aware that the Kinect's coordinate system has its origin at the sensor and provides coordinate values ranging roughly from -2.2 to 2.2 on the x-axis, from -1.6 to 1.6 on the y-axis, and from 0.0 to 4.0 on the z-axis (depth). Thus, you might need to apply some transformations.

Explain class, method, function? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I am not clear what these terms mean:
Class
Method
Function
Can you please explain these terms to me?
You should first begin with Object Oriented development (maybe http://en.wikipedia.org/wiki/Object-oriented_programming). Because the class, method and function topics are not Java-specific.
Then you can see how Java works and how to build classes with it.
A class is a way of representing a group of objects. Sun/Oracle describes more about a class in What is a class? For example a car is a class of motorized vehicles with four wheels (among other things)
A method is a section of code that is declared to take some arguments (things like numbers) and return a value of a given type. A method has a body that determines what it does. Other parts of your code can call that method, at which point the code in your method is run and the return value can be used by the code doing the calling.
The word function is not really used when discussing Java, but if it is used it is a synonym for method.

Why Pex is not massive [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Hi there: I was looking at a few videos, etc and I just cant help but wonder why Pex usage seems to be so low?
Are there any problems that are not obvious, or is it just a licence issue?
It's a very new tool and to work really well you need to use Code Contracts as well. It also catches a lot of issues like possible integer overflows that a lot of developers think they can just ignore. Pex is amazing and will take off eventually but it has a learning curve so it's going to take some time to percolate through the .Net ecosystem.
I've used it on a few new development projects and it has saved me two major bugs (not caught by normal unit tests) that would have taken at least a week to track down and fix normally plus a few smaller issues so I'm a big proponent of Pex. That said it takes a lot of work to get it producing good results on an existing code base of any size so how cost effective it is will need to be determined on a project by project basis.

Why do programming texts always use an "Employee" entity? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 13 years ago.
Is there something special about an Employee entity that makes it desirable to use it so frequently in programming texts?
Are there any other entities that would serve just as well?
Obviously; anything specifying a hierarchy will be helpful; Employee is used because it's most common and trivially understood conceptually (i.e. it's easy to visualise). It's harder to visualise B : A.
In case it's not obvious; it's used because it's useful for learning about OO in terms of the hierarchy/polymorphism functions, and allows it to direct relate to something almost everyone has experience with.
It is the same thing that happens with Introductions to programming where they use Animal as the base of an objects hierarchy. Maybe because everyone in this world knows what Employee and Animal mean!
It's all about hierarchy. Student / Teacher / Classes / School works too.