Köll & Sam Classroom Blog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    Originally posted by Killer42
    What is Phyton? Just a mistyped Python?

    Ohhh!! hahahahh,

    Python....

    To those java lovers that have experience in Python,

    What can you say about Python? Good?

    Comment

    • subeen
      New Member
      • Aug 2007
      • 8

      Download and view the slides from here: Why I love Python
      Python is good for desktop, web programming, mobile phone programming and game programming! (search google using 'pygame')

      Python is one of the three official languages of Google (other two are, C++ & Java).

      And you can also read: python vs java and python is not java

      Life is short ~ you need python. (But again, life is short, so you don't need a python to kill you) ;)

      regards,
      Subeen.

      Comment

      • sukatoa
        Contributor
        • Nov 2007
        • 539

        If my Applets can be embed in Python, then i will try!!!!

        I will use it... If not or there is a limit, then i will not...

        Comment

        • subeen
          New Member
          • Aug 2007
          • 8

          Originally posted by sukatoa
          If my Applets can be embed in Python, then i will try!!!!

          I will use it... If not or there is a limit, then i will not...
          hmm... try Jython (Java + Python)

          :-)

          regards,
          Subeen

          Comment

          • Dököll
            Recognized Expert Top Contributor
            • Nov 2006
            • 2379

            You do realise, of course, that you could be excommunicated from the VB community for such heresy?
            Can't begin to imagine, venturing uncharted waters:-)



            Of course us Java Samaritans will gently adopt the wise soul who saw the light
            and found the truth; we'll ignore the drooling ugly vb-droids that blindly, gnawing,
            wobble around in their own smelly droppings while looking silly all over; halleluya!

            kind regards,

            Jos ;-)
            It's a humbling experience, truly spectaular actually...


            Java is cool.

            I am inviting all of you to try Python. If you are a good Java programmer, you will be surprised :-)

            regards,
            Subeen

            Apprentice thus far, give and take I say two three years of intense studying, I can be be a good Samaritan, perhaps as skilled as you, I suspect you're having fun with it:-)



            Sure?

            What is in Phyton that has not on java?
            Perhaps more JAVA, hee hee...


            Enjoy your week-end everyone...
            Last edited by Dököll; Mar 1 '08, 02:23 AM. Reason: quote brackets

            Comment

            • SammyB
              Recognized Expert Contributor
              • Mar 2007
              • 807

              So, köll, how are your Applets? My Servlets are terrible. See my thread about them. BTW, unless you object, I'm changing this thred title to Köll & Sam Classroom Blog

              Comment

              • SammyB
                Recognized Expert Contributor
                • Mar 2007
                • 807

                Forgot to reply to your post 117 & 118:
                Originally posted by Dököll in 117
                I'd love to do web services, in fact would be helpful to an XML project I am working on for our forum articles. For now I am using ASP.NET to talk to SLQ DB, would be beneficial if I can submit threads via XML docs through ASP>NET.

                This is Java discussion so I'll switch up a bit. I wanted to say though in conclusion, you're the reason I am going to probably go for C#, having read an earlier post where you mentioned C# being one of the reasons you were able to embrace Java a bit better, thought to have read that. Java can therfore be my gateway to C#. Let me know if it holds true also using Java to understand C#...

                In a bit!
                You won't love to do Servelets in Java! But, C# plays very well with XML. And, C# is exactly like Java only much more consistent, better generics, has DotNet framework, and has real properties.

                Originally posted by Dököll
                This is rather familiar Sam, we actually wrote a ball program also, were able to size the balls and bounce at differents speed, pretty cool...

                I probably missed it but what book are you referring to?

                Is this guy an author Jos?

                Googling as in a bit but who's he?

                Where'd you disappear to anyway?

                See ya!
                My book is Java Programming by Shelly/Cashman/et al
                For Liskov, see http://en.wikipedia.org/wiki/Liskov_...tion_principle

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  Originally posted by SammyB
                  And he is a she; her name is Barbara Liskov; I wrote a 'howto' lately about her
                  substitution principle. In ordinary terms the substitution principle states that
                  if a program P using a class B has result R then for a class D if P has the same
                  result R on it, i.e. P(B) == P(D) then D *can be* a subclass of B. Read my
                  little article about it and keep that substitution principle in mind whenever you
                  want to design a derived class.

                  kind regards,

                  Jos

                  Comment

                  • Dököll
                    Recognized Expert Top Contributor
                    • Nov 2006
                    • 2379

                    You won't love to do Servelets in Java! But, C# plays very well with XML. And, C# is exactly like Java only much more consistent, better generics, has DotNet framework, and has real properties.
                    Good to know that much more about C# thanks, and also thanks for providing the information on your book, and on Liskov, should take a look at that howto... I am running to finish a project, in a bit:-)

                    Comment

                    • SammyB
                      Recognized Expert Contributor
                      • Mar 2007
                      • 807

                      Originally posted by Dököll
                      I am running to finish a project, in a bit:-)
                      Don't know if you're still doing Applets, but if so try JApplet instead of Applet. It allows you to use all of the Swing conponents. I'm using it for my final project: can't believe that we never used them.

                      Comment

                      • Dököll
                        Recognized Expert Top Contributor
                        • Nov 2006
                        • 2379

                        Originally posted by SammyB
                        Don't know if you're still doing Applets, but if so try JApplet instead of Applet. It allows you to use all of the Swing conponents. I'm using it for my final project: can't believe that we never used them.
                        That's a good idea, JApplet huh! Will definitely look into that. Hats off on the name of the thread Sam... By the way, let's drill our teeth into this one.

                        I have been at this for almost two weeks. I want to modify below code to restrict letters in input box and to also look at a number and decide whether valid or not and to continue.

                        [CODE=JAVA]
                        public int getAge(String prompt) {

                        String inputStr;
                        int age;

                        while (true) {
                        inputStr = JOptionPane.sho wInputDialog(nu ll, prompt);

                        try {
                        age = Integer.parseIn t(inputStr);

                        if (age < 0) {
                        throw new Exception("Nega tive age is invalid");
                        }

                        return age; //input okay so return the value & exit

                        } catch (NumberFormatEx ception e) {

                        JOptionPane.sho wMessageDialog( null, "'" + inputStr
                        + "' is invalid\n"
                        + "Please enter digits only");

                        } catch (Exception e) {

                        JOptionPane.sho wMessageDialog( null, "Error: "
                        + e.getMessage()) ;
                        }
                        }
                        }
                        [/CODE]

                        It is calculating user's age. This works fine, I just need to make below work nicely with above code:-o):

                        [CODE=JAVA]
                        while (loanAmount < 100 || loanAmount > 1000000) {
                        JOptionPane.sho wMessageDialog( null,
                        "Invalid entry, please enter number between 100 and 100000");

                        inputStr = JOptionPane.sho wInputDialog(nu ll,
                        "Loan Amount (Dollars + Cents):");
                        loanAmount = Double.parseDou ble(inputStr);

                        }

                        [/CODE]


                        Above works also and I have managed to get them to work hand in hand, except for when I fall out of the loop, I get n error, even though it works up until then.

                        Let me comment the code and run it. then will post. But with the above how do you see in your own way where one can restrict letters being entered in our input box, of course accept only numbers but of a certain value. If I could get some guide or an idea, however best to approach it, I may be able to get it.

                        How would you handle this one?

                        Thanks!

                        Köll

                        Comment

                        • SammyB
                          Recognized Expert Contributor
                          • Mar 2007
                          • 807

                          As you said, you want to rewrite the second to look like the first, so you make the while loop into while (true) and move the range test into the non-negative test. But, better yet, combine them both into one function that has inputs: the range & an error message. The function then prompts, parses, range checks, loops on an exception until you have a good number that it returns. Then you don't clutter up your program with all of the ugly try catch. However, you also should allow the user to bail out of that loop by throwing its own "bail-out" exception, but that's probably too advanced for you now.

                          BTW, did you know that you can have Eclipse write the try-catch for you? Just select the code and use the Source, Surround with... menu. Even better, in a class, after defining the properties at the top, you can select them and use the Source, Generate Getter & Setters... to generate all of those methods for you. Very cool!

                          Back to the first subject, of course what you really want is a numeric textbox control, then you could make your own input box. Cannot find any such control, but I'm sure it exists. Where is it, Jos?

                          Comment

                          • JosAH
                            Recognized Expert MVP
                            • Mar 2007
                            • 11453

                            Originally posted by SammyB
                            Back to the first subject, of course what you really want is a numeric textbox control, then you could make your own input box. Cannot find any such control, but I'm sure it exists. Where is it, Jos?
                            It doesn't exist but all the building blocks are there (as you already know).
                            It'd be easy to write your own version, possibly including range checks.

                            kind regards,

                            Jos

                            Comment

                            • SammyB
                              Recognized Expert Contributor
                              • Mar 2007
                              • 807

                              Originally posted by JosAH
                              It doesn't exist but all the building blocks are there (as you already know).
                              It'd be easy to write your own version, possibly including range checks.

                              kind regards,

                              Jos
                              Well, as Jos says, it is easy, I just modified the UpperCaseField example in http://java.sun.com/j2se/1.4.2/docs/...TextField.html, but I really don't understand it. I let Jos explain my code.
                              Here is the test driver:
                              [code=java]
                              import java.awt.*;
                              import javax.swing.*;
                              public class NumericTest extends JApplet
                              {
                              public void init()
                              {
                              JPanel p = new JPanel();
                              p.setLayout(new GridLayout(1,2) );
                              JLabel lbl = new JLabel("Enter Number:");
                              NumericField tb = new NumericField(1) ;
                              p.setBackground (Color.LIGHT_GR AY);
                              p.add(lbl);
                              p.add(tb);
                              this.getContent Pane().add(p);
                              this.setSize(20 0, 40);
                              }
                              }
                              [/code]
                              and here is the NumericField class
                              [code=java]
                              import javax.swing.*;
                              import javax.swing.tex t.*;
                              public class NumericField extends JTextField
                              {
                              public NumericField(in t cols)
                              {
                              super(cols);
                              }
                              protected Document createDefaultMo del()
                              {
                              return new NumericDocument ();
                              }
                              static class NumericDocument extends PlainDocument
                              {
                              public void insertString(in t offs, String str, AttributeSet a)
                              throws BadLocationExce ption
                              {
                              if (str == null)
                              {
                              return;
                              }
                              char[] c = str.toCharArray ();
                              StringBuilder s = new StringBuilder() ;
                              for (int i = 0; i < c.length; i++)
                              {
                              if (Character.isDi git(c[i])) s.append(c[i]);
                              }
                              super.insertStr ing(offs, s.toString(), a);
                              }
                              }
                              }
                              [/code]

                              Comment

                              • Dököll
                                Recognized Expert Top Contributor
                                • Nov 2006
                                • 2379

                                Great help here guys, thanks. Will go to work on your examples Sam, try to build my own from it.

                                In a bit, and thanks also for the link!

                                Köll

                                Comment

                                Working...