Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Java Help

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
Rep Power: 10
Sionofdarkness is on a distinguished road
Default Data and Classes

I know what data is, I mean outside of programming languages, but I read that data and methods make classes. 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,035
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
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 class. It could be ints, floats, or even other classes.
__________________
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
Rep Power: 10
Sionofdarkness is on a distinguished road
Default

There can be classes within a class? Would that make it a "sub-class" (I've never heard the term but I assume 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,035
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
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 subclass usually refers to a class that has been derived from another class. For example, the class of dogs is a subclass of the class of animals. (This terminology might come from set theory). A class within a class might be called a member class.

As far as can it be done, yes. Consider your car: it has an engine, wheels, etc. So if you are modeling it with classes, you would have an engine class, a wheel class, and a car class 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
Rep Power: 10
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,035
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
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:
class piece
{
  public:
    bool moveTo(x,y);
    bool isThreatend();
    TYPE pieceType();
  private:
    COLOR color;
}

class pawn : piece
{
  private:
    bool EnPassante;
}

pawn myPawn;
piece myPiece;
myPiece has one data values: myPiece.color
myPawn has two data value: myPawn.color (inherited from the piece class) and myPawn.EnPassante
COLOR is an enumeration for the colors of chess pieces (Black and White).

Now I can make another class:

Code:
class Board
{
  public:
    void PlayGame();
  private:
    piece pieces[16][2];
}
This class has 32 pieces as data, each having a color and the ability to move.

Now, with a few more classes 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 class which contains pointers to other classes Sheemer C and C++ 0 08-21-2007 01:17 AM
Multiple classes in one namespace NeedHelp Managed C++ 2 06-29-2006 03:35 PM


All times are GMT -5. The time now is 03:19 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 65%

Ads