|
||||||
| Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I know what data is, I mean outside of programming languages, but I read that data and methods make cl***es. I now know what methods are, but what is "data". Is it just everything else, like the syntax and such?
|
| Sponsored Links |
|
|
|
|||||
|
the "data" would be the variables within the cl***. It could be ints, floats, or even other cl***es.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
A subcl*** usually refers to a cl*** that has been derived from another cl***. For example, the cl*** of dogs is a subcl*** of the cl*** of animals. (This terminology might come from set theory). A cl*** within a cl*** might be called a member cl***.
As far as can it be done, yes. Consider your car: it has an engine, wheels, etc. So if you are modeling it with cl***es, you would have an engine cl***, a wheel cl***, and a car cl*** that has an engine and an array of wheels as members. The engine would have information such as the number of cylinders. The wheels would have information such as size and if they're flat or spare. The car would include the manufacturer.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
I'm a little rusty on Java, so my example will be in C++.
Code:
cl*** piece
{
public:
bool moveTo(x,y);
bool isThreatend();
TYPE pieceType();
private:
COLOR color;
}
cl*** pawn : piece
{
private:
bool EnP***ante;
}
pawn myPawn;
piece myPiece;
myPawn has two data value: myPawn.color (inherited from the piece cl***) and myPawn.EnP***ante COLOR is an enumeration for the colors of chess pieces (Black and White). Now I can make another cl***: Code:
cl*** Board
{
public:
void PlayGame();
private:
piece pieces[16][2];
}
Now, with a few more cl***es and some code for the methods, you have a chess program ![]()
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Issue writing to file: pointer to a cl*** which contains pointers to other cl***es | Sheemer | C and C++ | 0 | 08-21-2007 01:17 AM |
| Multiple cl***es in one namespace | NeedHelp | Managed C++ | 2 | 06-29-2006 03:35 PM |
| Xav | ........ | 1322.18 |
| MeTh0Dz|Reb0rn | ........ | 1053.7 |
| morefood2001 | ........ | 879.43 |
| John | ........ | 877.37 |
| marwex89 | ........ | 869.98 |
| WingedPanther | ........ | 830.24 |
| Brandon W | ........ | 735.07 |
| chili5 | ........ | 309.39 |
| Steve.L | ........ | 239.84 |
| dcs | ........ | 216.02 |
Goal: 100,000 Posts
Complete: 82%