Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 51
Like Tree1Likes

Thread: Getting all info from one class to another

  1. #21
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: Getting all info from one class to another

    Quote Originally Posted by NitroDev View Post
    Nope i wan to learn java too so none of that copy paste stuff
    Then stop feeding this thread, turn on your brain and start thinking about it :/
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  2. #22
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: Getting all info from one class to another

    I must pray for forgiveness to the gods of programming, for I understood your requirement and it is quite stupid and yet I will help you to fail completely in life as programmer by giving you code as you asked.

    But bear in mind the way you are asking this question and the amount of effort you are putting in this, or rather, not putting in this will only earn you failure.

    Java Code:
    import java.util.Scanner;
     
    public class Character_Creation {
         
        public static void main(String[] args) {
            Scanner stats = new Scanner(System.in); //creating the scanner object
     
            System.out.println("Enter your name:"); //ask a question
            String name = stats.nextLine();   //get a String response and store it in a String called "name"
            System.out.println("So your name is " + name + "!");
             
            System.out.println("What is your age?"); //Ask another question
            int age = stats.nextInt();
             
            //now we need to check something
            if (age < 18) {                   //if statements DO NOT have semicolons at the end.
                System.out.println("Too Young!");
            } else {  //if the previous check returns false, this will be called.
                System.out.println("Welcome!");
               World_Creation.main(args);
            }
        }
    }
    Java Code:
    public class World_Creation {
     
        public static void main(String[] args) {
           //to here
            System.out.println("Now we must create a world for you!");
            // TODO Auto-generated method stub
     
        }
     
    }
    This is what you are demanding, this is something that should neve be written. Now, pelase go back to studing from the start and do try to learn something instead of "this". And do keep this code so that you can revisit it and see how much it lacked.

    Excuse me that I now have to go out and ckeab my soul.

  3. #23
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: Getting all info from one class to another

    It would be useful if you backup why Nitro should never do "this". The why is more important you know.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #24
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Getting all info from one class to another

    Hi,

    I want to add my view to this topic, too.

    It is quitehard to understand, what the core problem is. I think the understanding of objects is simply missing right now.

    When you develop something in an object oriented language like java, you create classes wich describes objects and then you create instances of that class (We just ignore static stuff right now!).

    Copying all information about an object: Why do you want to store all data of an object outside that object? If you want to have all details of a "Car" then it is quite common to just store the car object itself.

    So with your example you should split up the code itself. Why do you want a class "World_Creator"? If you want a world, then just create a class World and create an instance.

    if you want to have some kind of User, then just create a Class for it. So in your example you could create a class User with Name and age. You could have setter/getter for Name and Age. You could have a method that determines if the user is an adult (e.g. isAdult() which returns true if age is > 18).

    So in your Main you could handle the input but you create a User object first. Then you set name and age. You could create an instance of world and then call a method addUser(user) where user is the user object you created first.

    That would be an object oriented approach.

    With kind regards,

    Konrad

  5. #25
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: Getting all info from one class to another

    Ok, now that my soul is cleansed I can go back to the Pure State of OO(TM).

    (Jane Austin moment)The first reason that "this" should not be done is that it offends my sensibilities, just kidding.

    OO is an abstraction which closes the gap on how computer does things and how human beings think, in doing so it tries to make easier for an human being to understand the code whilst putting a "cognitive overload" on the part of the computer, but at some point the procedural world must meet the object world and thus main comes into play.

    The main method is a necessary evil where you have to bootstrap your object oriented perfect world in the dirty of bits and bytes and all those nagging electrons doing or not doing stuff in the realm of the concrete computer and bare wire.

    You should escape as soon as you could into the higher levels of the mental state of OO in main, instead of main tainting your code by doing main chaining of something the you would rather not be main taining. I agree, that was horrible. ;-)

    As it is, there is no OO at all in "this", just procedural with main, and that has additional complications, for once you do not have any state to keep except for the local variables that would be lost to the called main, you have a parameter list that hardly express the meaning of data you would pass if you so choose to use them to forward the collected info in the previous class.

    Besides main is a canonical entry point, which means that for an outsider, it is valid to start the application from the second main and that would not allow the execution of the necessary code for character data collection. More over, the names are in disagreement with Java standards, there is no proper separation of concerns here and even a hint of abstraction of obvious players here like Character, World, Login while the only existing classes are hints of actions, which would not be wrong in support the creation of the world and character with a CharacterGenerator and WorldGenerator which would put us in the clean air and ice caped mountains of Design Patterns with maybe a builder pattern.

  6. #26
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    946
    Rep Power
    2

    Default Re: Getting all info from one class to another

    To notivago: I appreciate the time you take to answer posts, but the way you are answering them is very hard to understand, especially for people who's language is not native English. Although I am Dutch and my English is far above average, I have to read your posts two or three times to make any sense. Let me share a few examples:


    Quote Originally Posted by notivago View Post
    ... in the dirty of bits and bytes and all those nagging electrons doing or not doing stuff in the realm of the concrete computer and bare wire....
    ... You should escape as soon as you could into the higher levels of the mental state of OO in main, instead of main tainting your code by doing main chaining of something the you would rather not be main taining. ...
    ... for once you do not have any state to keep except for the local variables that would be lost to the called main, you have a parameter list that hardly express the meaning of data you would pass if you so choose to use them to forward the collected info in the previous class.
    ... Besides main is a canonical entry point, which means that for an outsider, it is valid to start the application from the second main and that would not allow the execution of the necessary code for character data collection. More over, the names are in disagreement with Java standards, there is no proper separation of concerns here and even a hint of abstraction of obvious players here like Character, World, Login while the only existing classes are hints of actions, which would not be wrong in support the creation of the world and character with a CharacterGenerator and WorldGenerator which would put us in the clean air and ice caped mountains of Design Patterns with maybe a builder pattern.
    Wait, what?
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  7. #27
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: Getting all info from one class to another

    Ok,

    Is it that my English wrong? My grammar strange? The choice of words unusual or improper? The mingling of jokes counter-produtive? All of this?

    Not knowing the problem makes it hard to fix it.

  8. #28
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: Getting all info from one class to another

    If I had to be honest, it is all of the above. Sentences have to "flow", and when I read your post my brain constantly has to adapt to keep following your train of thought.

    Note that humor is fine, but is better saved as a PS or a followup post.
    Last edited by gimbal2; 02-13-2014 at 03:08 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #29
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    946
    Rep Power
    2

    Default Re: Getting all info from one class to another

    Quote Originally Posted by notivago View Post
    Ok,

    Is it that my English wrong? My grammar strange? The choice of words unusual or improper? The mingling of jokes counter-produtive? All of this?

    Not knowing the problem makes it hard to fix it.
    I usually go for short, to-the-point answers, if needed add a short, working example. You have to keep in mind that the devs who post their issues here are most of the time very new-to-Java-devs. Rambling about nagging electrons, realm of the concrete computer and bare wire, clean air and ice caped mountains don't add to their understanding of your explanation. Keep the jokes, wordplays and other hilarities to a minimum. Or put one or two at the end.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  10. #30
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: Getting all info from one class to another

    Thank you guys,

    I appreciate the honesty, I will keep it in mind from now on.

    May the code be with you.

  11. #31
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: Getting all info from one class to another

    I found it a worthwhile reading, although I disagree about the 'OO is a perfect world' part; functional programming comes close too and Java is just crappy when it comes to functional programming; FP can be much closer to the way of human thinking than OO does (at least to my way of thinking).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  12. #32
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: Getting all info from one class to another

    Agreed Jos,

    I never hide I am a OO Zealot and I find myself lacking badly at functional.

    And then you have to use apples as apples and hammers as hammers, if you want functional, go lisp, clojure, OCaml and other such beasts. Although you would be a Heathen.

    If you are doing java, OO is the paradigm, you can even borrow from functional here and there so that you try to enforce immutable data for threading and stuff like that. But the essential must be learned first.

    May the code be with you.

  13. #33
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Getting all info from one class to another

    Quote Originally Posted by JosAH View Post
    I found it a worthwhile reading, although I disagree about the 'OO is a perfect world' part; functional programming comes close too and Java is just crappy when it comes to functional programming; FP can be much closer to the way of human thinking than OO does (at least to my way of thinking).

    kind regards,

    Jos
    Hi Jos,

    sorry, but I simply have to disagree with your writing at all:

    a) "OO is a perfect world" - nobody said that.
    b) Java is not a functional programming language so yes - it is crap regarding that. (If someone gives you a nice car as present: Just give it to me. It is a crap solution vor diving in seas and also crap regarding flying around. So a nice porsche or lamborghini is only crap and you should give such cars to me :) )

    And of course: This simply does not lead anywhere. Concentrate on the needs of the people. If someone wants to learn java or solve a java problem, then any FP stuff is simply nonsense and you should stop confusing beginners.

    Thank you and sorry for the off topic post.

    Konrad

  14. #34
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: Getting all info from one class to another

    Quote Originally Posted by kneitzel View Post
    a) "OO is a perfect world" - nobody said that.
    b) Java is not a functional programming language so yes - it is crap regarding that. (If someone gives you a nice car as present: Just give it to me. It is a crap solution vor diving in seas and also crap regarding flying around. So a nice porsche or lamborghini is only crap and you should give such cars to me :) )

    And of course: This simply does not lead anywhere. Concentrate on the needs of the people. If someone wants to learn java or solve a java problem, then any FP stuff is simply nonsense and you should stop confusing beginners.
    a) Reply #25 by Notivago:
    The main method is a necessary evil where you have to bootstrap your object oriented perfect world ...
    b) Java and functional programming languages are Turing complete; i.e. you can implement a Turing Machine in them and you can implement one language in the other and vice versa so your comparison doesn't make sense at all.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  15. #35
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: Getting all info from one class to another

    Quote Originally Posted by kneitzel View Post
    And of course: This simply does not lead anywhere. Concentrate on the needs of the people. If someone wants to learn java or solve a java problem, then any FP stuff is simply nonsense and you should stop confusing beginners.
    You can't fault someone for stating an opinion in an off-topic discussion. A bit of a fail post in my opinion.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  16. #36
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Getting all info from one class to another

    Hi Jos,

    I understood the writing of Notivago not as "OO is a perfect world" (What you seemd to understand). Instead I understood that the procedural stuff used with the static main function is not an object oriented design that a developer might want to have.

    And the fact that both development paradigmens are turing complete simply means that you can solve problems in both. But that simply means that you can put a car into a submarine or into a plane. So yes: you can fly with the car or dive inside a sea. So the example is still valid in my eyes.

    gimbal: Maybe you are correct. But I didn't see this thread as a complete off topic thread. I am used to focus on the person who asks for help. I was just wondering about the reply of Jos (and still do that) because I never read what he seemed to read.

    Konrad

  17. #37
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: Getting all info from one class to another

    Quote Originally Posted by kneitzel View Post
    And the fact that both development paradigmens are turing complete simply means that you can solve problems in both. But that simply means that you can put a car into a submarine or into a plane. So yes: you can fly with the car or dive inside a sea. So the example is still valid in my eyes.
    The fact that two programming languages are equivalent doesn't make a car, submarine or airplane equivalent; your comparison doesn't make sense at all.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  18. #38
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: Getting all info from one class to another

    Give it time. Just like all separate devices are being crammed into tiny little phones, I'm sure one day there will be cars that can travel through the sky and waters too.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  19. #39
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: Getting all info from one class to another

    Quote Originally Posted by gimbal2 View Post
    Give it time. Just like all separate devices are being crammed into tiny little phones, I'm sure one day there will be cars that can travel through the sky and waters too.
    I like to drive with the window open, while smoking; can I do that if my car were a submarine? Of course not silly; my cigarette would be extinguished;I hate that ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  20. #40
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: Getting all info from one class to another

    Hello, we're talking about the time where there is one world government and they TELL you if you are allowed to smoke or not.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 10
    Last Post: 04-20-2011, 02:03 AM
  2. Print info from a different class?
    By liquidtoon in forum New To Java
    Replies: 3
    Last Post: 11-01-2010, 01:19 PM
  3. Replies: 10
    Last Post: 06-17-2010, 04:22 AM
  4. How it is possible view info about class?
    By artemff in forum New To Java
    Replies: 3
    Last Post: 12-31-2009, 12:17 AM
  5. Getting Class info
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-06-2007, 02:46 PM

Posting Permissions

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