Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Java Help

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-22-2006, 11:42 AM
Sionofdarkness Sionofdarkness is offline
Programming Expert
 
Join Date: Jul 2006
Posts: 385
Credits: 0
Rep Power: 11
Sionofdarkness is on a distinguished road
Default Data and Cl***es

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-23-2006, 09:26 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,485
Last Blog:
wxWidgets is NOT code ...
Credits: 830
Rep Power: 28
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-29-2006, 12:31 PM
Sionofdarkness Sionofdarkness is offline
Programming Expert
 
Join Date: Jul 2006
Posts: 385
Credits: 0
Rep Power: 11
Sionofdarkness is on a distinguished road
Default

There can be cl***es within a cl***? Would that make it a "sub-cl***" (I've never heard the term but I ***ume that would be what they're called).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-29-2006, 02:40 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,485
Last Blog:
wxWidgets is NOT code ...
Credits: 830
Rep Power: 28
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-21-2006, 02:28 PM
Sionofdarkness Sionofdarkness is offline
Programming Expert
 
Join Date: Jul 2006
Posts: 385
Credits: 0
Rep Power: 11
Sionofdarkness is on a distinguished road
Default

Your examples, as always, are very helpful. Can you give an example using a real piece of code as well?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 08-23-2006, 09:18 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,485
Last Blog:
wxWidgets is NOT code ...
Credits: 830
Rep Power: 28
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

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;
myPiece has one data values: myPiece.color
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];
}
This cl*** has 32 pieces as data, each having a color and the ability to move.

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT -5. The time now is 02:18 AM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads