+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 30 of 30
Coding Thread, How to compare strings in Java in Coding and Web Development; Originally Posted by webman Code: Customer webman = new Customer(12345678, "Craig", "101 Front Street", 4000); webman.withdraw(200); You're not going to ...
  1. #16

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,855
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    181
    Quote Originally Posted by webman View Post
    Code:
    Customer webman = new Customer(12345678, "Craig", "101 Front Street", 4000);
    webman.withdraw(200);
    You're not going to assign that withdrawal to a variable somewhere, just let it fall into a null pointer?


    Quote Originally Posted by webman
    A class is like a blueprint, and creating an instance of an object is bringing it to life so you can interact with it.
    Unless you're working with abstract classes, which can't be instantiated -- wait, I'm taking this too seriously...

  2. #17

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,218
    Thank Post
    2,769
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    Quote Originally Posted by powdarrmonkey View Post
    Well not really, since subs can't return values... but I see what you mean.

    No. In a full OO language, add() would be a function of some object (like object.Add()) and it would take only one parameter, and add it to the value already possessed by the object:

    Code:
    Class myobject
    Dim mynumber As Integer
    
    Sub Add(othernum As Integer)
        mynumber = mynumber + othernum
    End Sub
    
    Function GetNumber() As Integer
        GetNumber = mynumber
    End Function
    
    End Class
    (my VB is rusty, but this is reasonable pseudo-code if nothing else...)

    This is the difference between procedural code, like your sub, and fully object-orientated methods like above.
    that just confused me more and went over my head - am trying to understand objects and you've created a class with functions inside of the class and then you have called the objects method ie myobject.add() not sure if thats helping or not ??

  3. #18

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318
    @powdarrmonkey Nah, I know it will just return false anyway

  4. Thanks to webman from:

    powdarrmonkey (17th June 2010)

  5. #19

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,855
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    181
    A class is a definition of what an object looks like to the programmer. Creating an object based on that class means it possesses all the functions, subs an variables you specified in it, like a blueprint.

  6. #20

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,218
    Thank Post
    2,769
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    abstract class - wooo slow down, too fast sensai !!

  7. #21

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,855
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    181
    Ignore the bit about abstract classes, you don't need them until you start to use inheritance.

  8. #22

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,218
    Thank Post
    2,769
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    Quote Originally Posted by powdarrmonkey View Post
    A class is a definition of what an object looks like to the programmer. Creating an object based on that class means it possesses all the functions, subs an variables you specified in it, like a blueprint.
    working with simple examples ( or as simple as possible please ) in this case we could say window or door

    the object would be the window or door

    to create the object you would require specific properties in order to describe or make the door or window ie

    height
    width
    depth
    material

    in the windows case you might have opacity ( as a shower door would have specific glass that would be difficult to see through in comparison to a normal window that you could see straight through , translucent, transparent etc )

    but then how would this apply in the programming sense with regards to if i wanted to create a 50% translucent window with height, width that were equal ie 500 * 500 with a depth / thickness of 10mm ??

    inheritance and abstract classes can take a back seat as that doesnt mean squat to me right now

  9. #23

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,855
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    181
    Maybe the traditional pets, dogs, and cats examples will help: Visual Basic/Object Oriented Programming - Wikibooks, collection of open-content textbooks

  10. #24

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318
    Code:
    Windows myWindow = new Window(50, 500, 500, 10);
    The myWindow variable is now a 50% translucent window measuring 500 x 500 and has a depth of 10mm. When you create a new object, it's constructor method is automatically called. The constructor method is named the same as the class. This is what the Window class might look like:

    Code:
    public class Window{
    
        private int mTranslucency;
        private int mWidth;
        private int mHeight;
        private int mThickness;
    
        public Window(pTranslucency, pWidth, pHeight, pThickness){
            // Take parameters from constructor and set attributes
            mTranslucency = pTranslucency;
            mWidth = pWidth;
            mHeight = pHeight;
            mThickness = pThickness;
        }
    
    
        public int getArea(){
             return mWidth * mHeight;
        }
    
    }
    I can now call myWindow.getArea() and it will give me the area.

  11. #25

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,218
    Thank Post
    2,769
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    Quote Originally Posted by powdarrmonkey View Post
    Maybe the traditional pets, dogs, and cats examples will help: Visual Basic/Object Oriented Programming - Wikibooks, collection of open-content textbooks
    ok gone through that and there are a few things that dont quite make sense

    There are two types of inheritance: implementation and interface.

    In the pet examples above an array of cPet objects is used to hold the pets.

    Implements cPet <-- is this the same as an include when using asp or c++ like including the header file ??

    If so then how come the cPet class has nothing in it ?

    thanks webman and pmonkey !!

    Side note - are there any cbt nuggets or anything that goes through all this sort of stuff in plain english as all these extra terms chucked in etc is not sinking in or making sense

    with ref to webmans window example where has the class created and he has one method to calculate the area, I presume you could do the same for transparency and use a switch case / select case to determine what type of glass anyone would want depending on the transparency value ie 0% would be plain glass, 50% would be a shower pane and 100% would be one way glass ??

    Then get it to return the result to the method in the same way I did above with my script sub which may have to be a main method or function in whatever language that is OOP c++ or java or w/e ??
    Last edited by mac_shinobi; 17th June 2010 at 11:29 PM.

  12. #26
    fawkers's Avatar
    Join Date
    Jun 2007
    Location
    Southend
    Posts
    193
    Thank Post
    32
    Thanked 22 Times in 21 Posts
    Blog Entries
    2
    Rep Power
    30
    Just to add my 2c in; I would HIGHLY recomend the book: Objects first with Java by David J. Barnes and Michael Kolling clciky

    A very good book coving the java language from an object standpoint as apposed to a procedual progomatical approach. (does that make sence?).

    Anyway again HIGHLY recomened as an introduction to programming in Java.

  13. #27

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,218
    Thank Post
    2,769
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    Quote Originally Posted by fawkers View Post
    Just to add my 2c in; I would HIGHLY recomend the book: Objects first with Java by David J. Barnes and Michael Kolling clciky

    A very good book coving the java language from an object standpoint as apposed to a procedual progomatical approach. (does that make sence?).

    Anyway again HIGHLY recomened as an introduction to programming in Java.
    Any decent books on C++ as apposed to java as I would much prefer to start with C++ on windows and my aim is to go towards objective C on the mac side

  14. #28

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,720
    Thank Post
    1,451
    Thanked 580 Times in 434 Posts
    Rep Power
    165
    The comparison operator would compare the unique objects and just wouldn't be the desired output.
    You see - that's where us old timers would start a fight.

    If an object looks like a pig, smells like a pig and grunts - its a pig!

    I don't care if its called gertrude or maisy - its still a pig

    But thanks for rationalising - I did notice when delclaring strings that there wern't highlighted in bold like the other data types but hadn't thought it through.

    @mac_shinobi

    I try to use obejcts (if someone else has coded them up - then they are great! but I usually just end up perverting a language and reverting to procedural thinking as much as possible for my own stuff and just misuse classes as procedures

    I'm just too old to change

    (runs away into a corner before the OOP mob come looking for me)
    Last edited by SimpleSi; 19th June 2010 at 08:42 AM.

  15. #29

    Join Date
    Feb 2009
    Posts
    45
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    11

    Java links

    root for all things Java
    Developer Resources for Java Technology

    Java Tutorials - follow 'Trails Covering the Basics' first
    The Java™ Tutorials

    Programmers Guide
    JDK 7 Documentation Index

    API - Javadocs
    Java Platform SE 7 b66



    JavaRanch - A Friendly Place for Java Greenhorns
    Java knowledge quiz at the 'Roundup'
    JavaRanch - a friendly place for Java greenhorns - Roundup


    Eclipse - IDE for Java (+ much more)
    Eclipse.org home


    Apache - open source stuff
    Welcome! - The Apache Software Foundation

  16. Thanks to mrwITch from:

    SimpleSi (6th July 2010)

  17. #30

    Join Date
    Feb 2009
    Posts
    45
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    11

    C++ Links

    Haven't programmed in C++ for years

    cplusplus.com - The C++ Resources Network

    Visual C++ Tutorials, Library, and More on MSDN

    About C, C++ and C#

    And of course - you can find something for most programming languages from places like Wrox
    Technology Books, Free Code Downloads, Ebooks, Blogs, Articles, P2P Forums - Wrox

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 1
    Last Post: 19th January 2010, 01:25 PM
  2. Compare Smoothwall with RM smart cache
    By nicholab in forum Internet Related/Filtering/Firewall
    Replies: 1
    Last Post: 13th January 2010, 05:20 PM
  3. [Video] Compare The Meerkat Babies
    By russdev in forum Jokes/Interweb Things
    Replies: 0
    Last Post: 20th August 2009, 11:27 AM
  4. [Website] You CAN compare the meerkat... dot com!
    By WithoutMotive in forum Jokes/Interweb Things
    Replies: 11
    Last Post: 21st January 2009, 09:19 PM
  5. Compare Values Above, Equal and Below
    By TwyloII in forum How do you do....it?
    Replies: 7
    Last Post: 16th January 2009, 12:20 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •