Vanilla Forums has been nominated for a second time in the CMS Critic "Critic's Choice" awards, and we need your vote! Read more here, and then do the thing (please).
Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

The beginner programming thread

2456763

Posts

  • GanluanGanluan Registered User regular
    edited November 2007
    So as part of one assignment I need to remove the "magic numbers" from a bit code. But they are all just different numbers to scale down a given input to make a pretty picture of a car, sometimes by 6, or 2/3 or 3... should I just make final static variables called like... SCALE_DOWN_BY_SIX, SCALE_DOWN_BY_TWO_THIRDS, SCALE_DOWN_BY_THREE, and so on, or is there a better way I should be naming these/going about with this?

    Damn this OOD&P class and its horrible teacher.

    Something similar to what you're doing would be fine. The main idea behind removing all magic numbers and using constants instead is that your code is basically documenting itself.

    scale * 6.37894 doesn't make much sense compared to scale * SCALE_FACTOR_SIX.

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    Ah, that makes sense. The assignment said to make it more self documenting as well, so I guess this is a part of it.

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • mastmanmastman Registered User regular
    edited November 2007
    I imagine you can find some PHP libraries already written to do standard stuff like read connectino properties from a file and create a connection for you.

    ByalIX8.png
  • MaximilianMaximilian Registered User
    edited November 2007
    So as part of one assignment I need to remove the "magic numbers" from a bit code. But they are all just different numbers to scale down a given input to make a pretty picture of a car, sometimes by 6, or 2/3 or 3... should I just make final static variables called like... SCALE_DOWN_BY_SIX, SCALE_DOWN_BY_TWO_THIRDS, SCALE_DOWN_BY_THREE, and so on, or is there a better way I should be naming these/going about with this?

    Damn this OOD&P class and its horrible teacher.

    You need to give your constants names that express the meaning of them and not the value. I hope I can explain this:

    In this case it mostly depends on how the value is chosen. If, say, these values can be chosen by the user (in a combo box or something), I would probably name them something like SCALE_LEVEL_1, SCALE_LEVEL_2 and so on (or better yet, create a lookup array). Like this, if the options for the user change you can just change the value of a certain SCALE_LEVEL.

    If the used value depends on a different thing you need to give it a different name. Perhaps it depends on current connection speed to a server, then you should name them something like SCALE_LEVEL_FAST_CONN, SCALE_LEVEL_SLOW_CONN and so on.

    If you do it like this, and somebody decides that for super fast connections you don't have to scale anything at all, you just need to change the value of SCALE_LEVEL_SUPER_FAST_CON to "1". If you would have called it SCALE_DOWN_BY_TWO, then for clarity's sake you would also have to change the name to DONT_SCALE (or something) and all of its occurences in the code. And this is exactly what you are trying to avoid when using constants.

    Simple rule: If you need to change the name of your constant whenever its value changes than the name is bad or you just don't need a constant at all.

    Did this help?

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    Hm, alright, that makes sense. I'll need to look at this code thoroughly to understand what each of these numbers are doing, because as far as I can tell these constants are just arbitrary ones to make a picture of a car based on a given width input.

    EDIT: When can the Java compiler tell what the exact method that will be called before a program executes? W/regards to polymorphism. I'm trying to find it in this chapter of my textbook, but I cannot.

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • MaximilianMaximilian Registered User
    edited November 2007
    EDIT: When can the Java compiler tell what the exact method that will be called before a program executes? W/regards to polymorphism. I'm trying to find it in this chapter of my textbook, but I cannot.

    It can't. When you call a virtual method it's decided at runtime which implementation is executed. The compiler just doesn't know. It only stores somethig like "Call method xyz on the object at this place.", and when the program executes, different methods get executed depending on the type of "the object at this place".

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    That's what I thought... hence why I am confused when there is a question in my book asking to name two situations where it can do just what I asked... weird. Hm. Google times...

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • MaximilianMaximilian Registered User
    edited November 2007
    Well, if you do
    MyType foo = new MyType();
    foo.someMethod()
    

    The compiler can probably determine that someMethod of type MyType will be called and optimize the dispatching away. But from a programming perspective this doesn't matter at all.

  • mausmalonemausmalone Registered User regular
    edited November 2007
    Recoil42 wrote: »
    Janin wrote: »
    Recoil42 wrote: »
    So I'm too lazy to make an "The Intermediate programming thread" but anyways, this'll suffice.

    So I'm messing around with PHP and SQL/MySQL, and well... there's something bugging me. Do you *really* put the username/password to the SQL database in every PHP file that wants to access it? Doesn't that seem... just a little insecure to anyone else?

    I mean, if there's ever an apache glitch, and a user gets the raw PHP file... all your data is compromised. No?

    Put connection details in an external configuration file, then create a PHP function to load + parse the file, and return a database connection based on the data contained. If you put the configuration file outside the webroot, a proper webserver won't display it.

    Ewww.. really? Is that what "everyone else" does, too?

    I don't even put it outside the the webroot (because my hosting company won't allow it). I actually have it set variables. The variables will never display unless I actually tell them to display.
    <?PHP
    $MYSQLDBName = "db";
    $MYSQLUser = "my_username";
    $MYSQLPassword = "my_password";
    ?>
    

    This is actually pretty damned secure because even if somebody knows where your config file is the web server will never serve that up as text that they can read. The only way they'd be able to read your database username and password would be if they had file access to your server ... and then you'd have bigger problems to worry about.

    The bigger danger is from SQL injection, but as long as you realize that you can take steps to prevent it.

    266.jpg
  • JaninJanin Registered User
    edited November 2007
    mausmalone wrote: »
    Recoil42 wrote: »
    Janin wrote: »
    Recoil42 wrote: »
    So I'm too lazy to make an "The Intermediate programming thread" but anyways, this'll suffice.

    So I'm messing around with PHP and SQL/MySQL, and well... there's something bugging me. Do you *really* put the username/password to the SQL database in every PHP file that wants to access it? Doesn't that seem... just a little insecure to anyone else?

    I mean, if there's ever an apache glitch, and a user gets the raw PHP file... all your data is compromised. No?

    Put connection details in an external configuration file, then create a PHP function to load + parse the file, and return a database connection based on the data contained. If you put the configuration file outside the webroot, a proper webserver won't display it.

    Ewww.. really? Is that what "everyone else" does, too?

    I don't even put it outside the the webroot (because my hosting company won't allow it). I actually have it set variables. The variables will never display unless I actually tell them to display.
    <?PHP
    $MYSQLDBName = "db";
    $MYSQLUser = "my_username";
    $MYSQLPassword = "my_password";
    ?>
    

    This is actually pretty damned secure because even if somebody knows where your config file is the web server will never serve that up as text that they can read. The only way they'd be able to read your database username and password would be if they had file access to your server ... and then you'd have bigger problems to worry about.

    The bigger danger is from SQL injection, but as long as you realize that you can take steps to prevent it.

    He was specifically asking how to avoid compromising his password if his server was misconfigured to send PHP scipts as plain text, which your solution does not address. Get a better hosting provider.

    [SIGPIC][/SIGPIC]
  • MKRMKR Registered User regular
    edited November 2007
    Keep the config file above the web root.

  • HalibutHalibut Registered User regular
    edited November 2007
    No love for Java in this thread? I suppose a dynamic language is probably easier to learn for beginners.

    There's a language modeled after Ruby called Groovy. It's pretty cool because it has a very Ruby-like syntax (most of Ruby's core language features like dynamic typing, closures, etc...), but it runs on Java's JVM. It can also be compiled to Java .class files and then imported in any Java class (and vice versa). This allows a lot of quick prototyping opportunities where you can create an implementation of some component in Groovy and replace it later with a Java implementation if you need to.

  • JaninJanin Registered User
    edited November 2007
    Halibut wrote: »
    No love for Java in this thread? I suppose a dynamic language is probably easier to learn for beginners.

    There's a language modeled after Ruby called Groovy. It's pretty cool because it has a very Ruby-like syntax (most of Ruby's core language features like dynamic typing, closures, etc...), but it runs on Java's JVM. It can also be compiled to Java .class files and then imported in any Java class (and vice versa). This allows a lot of quick prototyping opportunities where you can create an implementation of some component in Groovy and replace it later with a Java implementation if you need to.

    There's a "Static Languages" section, but I'd rather not put too much of that stuff in the OP. I'm sure everybody in the thread would be happy to help with Java questions, but if somebody stumbles in wanting to learn the basics I'd rather they learn with an easy language.

    [SIGPIC][/SIGPIC]
  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    Could one answer for that question I asked above be if there is no superclass of that class that contains a method with the same signature?

    Hmmm

    Exact question being this:
    In Java, a method call on an object such as x.f() is resolved when the program executes, not when it is compiled, in order to support polymorphism. Name two situations where the Java compiler can determine the exact method to be called before the program executes.

    Even if the one I mentioned is one of those... I can't think of the other..?

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • JaninJanin Registered User
    edited November 2007
    Could one answer for that question I asked above be if there is no superclass of that class that contains a method with the same signature?

    Hmmm

    Exact question being this:
    In Java, a method call on an object such as x.f() is resolved when the program executes, not when it is compiled, in order to support polymorphism. Name two situations where the Java compiler can determine the exact method to be called before the program executes.

    Even if the one I mentioned is one of those... I can't think of the other..?

    Is it possible in Java to have non-virtual methods?

    [SIGPIC][/SIGPIC]
  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    Hey, anyone know of any good sites for general resources on OOP?

    I need to find and define different "super" patterns, just looking up the definitions on the web, and I could find most on wikipedia or other sites, but I'm not sure how to define Fundamental patterns... the other ones are pretty simple, like a Creational pattern is obviously one that deals with the instantiation process.

    Hm. Design... what madness. Important I guess though.

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • HalibutHalibut Registered User regular
    edited November 2007
    Janin wrote: »
    Could one answer for that question I asked above be if there is no superclass of that class that contains a method with the same signature?

    Hmmm

    Exact question being this:
    In Java, a method call on an object such as x.f() is resolved when the program executes, not when it is compiled, in order to support polymorphism. Name two situations where the Java compiler can determine the exact method to be called before the program executes.

    Even if the one I mentioned is one of those... I can't think of the other..?

    Is it possible in Java to have non-virtual methods?

    That's a good point. If a method is declared final, then no child class can override it, so if you had something like this:
    public class ParentClass{
        public final void someMethod(){ //do something}
    }
    
    Then you will get a compiler error if you try to do something like this:
    public class ChildClass extends ParentClass{
        public void someMethod(){//compiler error}
    }
    

    Another case where the compiler would know the exact class that a method is invoked for would be for static methods.

  • JaninJanin Registered User
    edited November 2007
    Hey, anyone know of any good sites for general resources on OOP?

    I need to find and define different "super" patterns, just looking up the definitions on the web, and I could find most on wikipedia or other sites, but I'm not sure how to define Fundamental patterns... the other ones are pretty simple, like a Creational pattern is obviously one that deals with the instantiation process.

    Hm. Design... what madness. Important I guess though.

    Ewww, patterns. Wiki has pages on Fundamental and Creational desgin patterns. If your library has the Gang of Four book, that would be a good reference.

    [SIGPIC][/SIGPIC]
  • HalibutHalibut Registered User regular
    edited November 2007
    Head First Design Patterns is probably the best book I've read on patterns. It's an easy read, and the material is presented really well. And you won't find anything completely obscure. It's all pretty useful for a professional (OO) software developer.

  • JaninJanin Registered User
    edited November 2007
    Halibut wrote: »
    Head First Design Patterns is probably the best book I've read on patterns. It's an easy read, and the material is presented really well. And you won't find anything completely obscure. It's all pretty useful for a professional (OO) software developer.

    Jeff Atwood had a bit of advice about this book, which I agree with.
    Beginning developers never met a pattern or an object they didn't like. Encouraging them to experiment with patterns is like throwing gasoline on a fire. And yet that's exactly what this book does [...] Do you really want a junior developer using patterns everywhere? It's about as safe as encouraging them to "experiment" with a gas-powered chainsaw. The best way to learn to write simple code is to write simple code! Patterns, like all forms of compexity, should be avoided until they are absolutely necessary. That's the first thing beginners need to learn. Not the last thing.

    [SIGPIC][/SIGPIC]
  • JasconiusJasconius sword criminal Flo-ridaRegistered User regular
    edited November 2007
    Yes thank you.

    I picked up a book on Actionscript 3 design patterns, and after 2 chapters on OOP principles in Actionscript, all I can think of was "I have no valid use for any of this". Because most of the work I do in Flash is small-scale.

    And the two other AS3 books I picked up both basically tell you to completely OOP even the simplest things.

    OOP is nice but if it causes you to take twice as long to do something, gotta ask yourself if that lost time will ever repay in the future. In Actionscript the answer is usually no because of the nature of the projects, in ASP.NET the answer is almost always yes because you're repeating similar operations on many pages.

    Your mileage may vary.

  • mausmalonemausmalone Registered User regular
    edited November 2007
    Janin wrote: »
    (snip)

    He was specifically asking how to avoid compromising his password if his server was misconfigured to send PHP scipts as plain text, which your solution does not address. Get a better hosting provider.

    .... why would I change my hosting provider? My server doesn't serve PHP as plain text. Never will.

    And if your server was misconfigured to send PHP scripts as plain text instead of executing them, then nothing PHP would work ever. period. end of story. If you can't run PHP at all, then it's not likely you're going to start MySQL development on it.

    First get PHP running. Then try to use it. Not the other way around.

    266.jpg
  • MKRMKR Registered User regular
    edited November 2007
    mausmalone wrote: »
    Janin wrote: »
    (snip)

    He was specifically asking how to avoid compromising his password if his server was misconfigured to send PHP scipts as plain text, which your solution does not address. Get a better hosting provider.

    .... why would I change my hosting provider? My server doesn't serve PHP as plain text. Never will.

    And if your server was misconfigured to send PHP scripts as plain text instead of executing them, then nothing PHP would work ever. period. end of story. If you can't run PHP at all, then it's not likely you're going to start MySQL development on it.

    First get PHP running. Then try to use it. Not the other way around.

    Issues pop up from time to time where scripts are sent as plain text. It happens to good providers too.

  • mausmalonemausmalone Registered User regular
    edited November 2007
    MKR wrote: »
    (snip)

    Issues pop up from time to time where scripts are sent as plain text. It happens to good providers too.

    I've never seen this happen to any provider, either good or bad. Is there an example of anything anywhere that causes this? The only way I could think of it happening is if you removed all of the PHP modules from apache's config and then restarted apache. It's something you'd have to do on purpose, not by a common (or even uncommon) error. Or you could blow away PHP by mistake but then I'm pretty sure you'd get a 500 internal server error.

    "Issues pop up" that apparently I've never seen on any site I've ever visited at any time anywhere on the internet over the span of more than a decade? I have a hard time believing that something that rare can even be considered a legitimate problem.

    266.jpg
  • MKRMKR Registered User regular
    edited November 2007
    mausmalone wrote: »
    MKR wrote: »
    (snip)

    Issues pop up from time to time where scripts are sent as plain text. It happens to good providers too.

    I've never seen this happen to any provider, either good or bad. Is there an example of anything anywhere that causes this? The only way I could think of it happening is if you removed all of the PHP modules from apache's config and then restarted apache. It's something you'd have to do on purpose, not by a common (or even uncommon) error. Or you could blow away PHP by mistake but then I'm pretty sure you'd get a 500 internal server error.

    "Issues pop up" that apparently I've never seen on any site I've ever visited at any time anywhere on the internet over the span of more than a decade? I have a hard time believing that something that rare can even be considered a legitimate problem.

    This is all pretty irrelevant. A question was asked, a solution was offered (putting the config file above the web root). If it matters to you so much, make a thread or something.

  • JaninJanin Registered User
    edited November 2007
    Jasconius wrote: »
    Yes thank you.

    I picked up a book on Actionscript 3 design patterns, and after 2 chapters on OOP principles in Actionscript, all I can think of was "I have no valid use for any of this". Because most of the work I do in Flash is small-scale.

    And the two other AS3 books I picked up both basically tell you to completely OOP even the simplest things.

    OOP is nice but if it causes you to take twice as long to do something, gotta ask yourself if that lost time will ever repay in the future. In Actionscript the answer is usually no because of the nature of the projects, in ASP.NET the answer is almost always yes because you're repeating similar operations on many pages.

    Your mileage may vary.

    Actionscript is basically the same as Javascript, so any book you pick up should have stressed functional and prototype-based programming. If it had objects anywhere in it (aside from "how to port OOP code to..."), it's not a good book.
    mausmalone wrote: »
    Janin wrote: »
    (snip)

    He was specifically asking how to avoid compromising his password if his server was misconfigured to send PHP scipts as plain text, which your solution does not address. Get a better hosting provider.

    .... why would I change my hosting provider? My server doesn't serve PHP as plain text. Never will.

    Your hosting provider doesn't allow you to put files outside the webroot. That's idiotic.
    mausmalone wrote: »
    And if your server was misconfigured to send PHP scripts as plain text instead of executing them, then nothing PHP would work ever. period. end of story. If you can't run PHP at all, then it's not likely you're going to start MySQL development on it.

    First get PHP running. Then try to use it. Not the other way around.

    And if you get PHP running, have it serving an important site, and then some intern at the hosting company fucks up a config file and whoooooops all your passwords are exposed? What then? If your company had allowed you to store files outside the webroot, the risk would be hugely reduced. For that matter, it doesn't even need to be the provider's fuck-up - maybe a developer working on your site put in one too many "?>"s and exposed half the page's source. If you had passwords sitting in that half, you've got trouble.

    [SIGPIC][/SIGPIC]
  • MKRMKR Registered User regular
    edited November 2007
    My webhost actually advises users to put any includes and such that don't need to be web-viewable above the web root.

  • JasconiusJasconius sword criminal Flo-ridaRegistered User regular
    edited November 2007
    Janin wrote: »
    Jasconius wrote: »
    Yes thank you.

    I picked up a book on Actionscript 3 design patterns, and after 2 chapters on OOP principles in Actionscript, all I can think of was "I have no valid use for any of this". Because most of the work I do in Flash is small-scale.

    And the two other AS3 books I picked up both basically tell you to completely OOP even the simplest things.

    OOP is nice but if it causes you to take twice as long to do something, gotta ask yourself if that lost time will ever repay in the future. In Actionscript the answer is usually no because of the nature of the projects, in ASP.NET the answer is almost always yes because you're repeating similar operations on many pages.

    Your mileage may vary.

    Actionscript is basically the same as Javascript, so any book you pick up should have stressed functional and prototype-based programming. If it had objects anywhere in it (aside from "how to port OOP code to..."), it's not a good book.

    Well, not completely. With the approach of Adobe Air and Flex there is a much bigger emphasis with Actionscript 3 for large scale applications, so the OOP has some relevance. Unfortunately their editor tools are pretty crappy for OOP development in my opinion. When you create a new class you can't even get info on it in code assist like in Visual Studio. They are a whole major release away from anyone taking Actionscript 3 seriously, methinks.

    I bought the books assuming that AS3 was some sort of replacement for 2, hahaha, not really.

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    If I have an Label that contains an Icon, part of which I want to change the color of... hm, shit... and the part that I want to change the color of is a Rectangle2D that is defined within the draw method of the shape that the Icon is representing... shit, I don't even know what to call.

    Do I getGraphics() from the label so I have the graphics object? Then what?

    And there's a repaint in there somewhere...

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • MKRMKR Registered User regular
    edited November 2007
    If I have an Label that contains an Icon, part of which I want to change the color of... hm, shit... and the part that I want to change the color of is a Rectangle2D that is defined within the draw method of the shape that the Icon is representing... shit, I don't even know what to call.

    Do I getGraphics() from the label so I have the graphics object? Then what?

    And there's a repaint in there somewhere...

    First you need to say which language you're using. :P

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    It's in Java. Blah. This seems like it should be very simple, but it would have helped if our teacher taught us anything.

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • HalibutHalibut Registered User regular
    edited November 2007
    Janin wrote: »
    Halibut wrote: »
    Head First Design Patterns is probably the best book I've read on patterns. It's an easy read, and the material is presented really well. And you won't find anything completely obscure. It's all pretty useful for a professional (OO) software developer.

    Jeff Atwood had a bit of advice about this book, which I agree with.
    Beginning developers never met a pattern or an object they didn't like. Encouraging them to experiment with patterns is like throwing gasoline on a fire. And yet that's exactly what this book does [...] Do you really want a junior developer using patterns everywhere? It's about as safe as encouraging them to "experiment" with a gas-powered chainsaw. The best way to learn to write simple code is to write simple code! Patterns, like all forms of compexity, should be avoided until they are absolutely necessary. That's the first thing beginners need to learn. Not the last thing.

    I agree with part of this statement. There is a difference between knowing how a pattern can help improve your software, and knowing when your software really needs that improvement. For simple applications, you might not get a lot of use out of them, and you should always stop and think about why you might need to use one.

    However, the poster was asking about different types of patterns, and I have not read a book that even remotely explains them as well as the Head First one. I didn't really read the link, but the part you quoted says that beginning developers shouldn't experiment with patterns. Experimenting is the best way to learn when to use them and when not to use them.

    That said, until you can see a problem and can immediately say "pattern xyz would be a good fit here for a,b,c, and d reasons" you probably shouldn't be using them on any project with importance. If you are a junior developer at a software company, you normally won't be making that kind of decision without the aid of a more senior developer anyway. If you are a student, you obviously shouldn't be using an unfamiliar pattern on a project the night before it is due. If you have never programmed before you shouldn't start with patterns, and the book is not intended for people who do not have at least a basic understanding of OO concepts.

    On top of that, the risks of experimentation in a "real" project can be greatly reduced with the help of things like version control, or asking a mentor/teacher for help. I don't think the goal of the book was to tell beginning programmers to go back and modify the source code of a project behind the backs of their peers or team leads. I would hope that no one is that stupid.

  • mausmalonemausmalone Registered User regular
    edited November 2007
    It's in Java. Blah. This seems like it should be very simple, but it would have helped if our teacher taught us anything.

    Sometimes Java can be the devil language if you want to do something simple. And then for other more complicated things it can be a breeze. It's strange that way.

    Anyhow, it would help if you copied & pasted the code you want to edit so that we can see what you're talking about.

    266.jpg
  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    Alright, well, I've made my own modifcations to the code for other purposes, because we were basically supposed to extend the functionality in various parts of it... I'll just post the unmodified code, because it'd be a mess, as I've added various sliders and buttons to do different things:
    animation tester:
    Spoiler:

    carshape:
    Spoiler:

    moveableshape
    Spoiler:


    ShapeIcon:
    Spoiler:

    So basically I know how to add buttons and actionlisteners for those buttons to the animation tester class...
    I made 3 seperate buttons in my code, one each for red, blue, and green. I'm trying to figure out how to make it so that each button fills in the body of the car to be the given color. Would it be smart of me to have the car be initially filled as one color? That I can do. It's just I'm not sure which object's methods I should be calling to change that color within the button... I know I need to set some graphics object to a color, and then repaint, I guess?

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • jothkijothki Registered User regular
    edited November 2007
    mausmalone wrote: »
    It's in Java. Blah. This seems like it should be very simple, but it would have helped if our teacher taught us anything.

    Sometimes Java can be the devil language if you want to do something simple. And then for other more complicated things it can be a breeze. It's strange that way.

    Anyhow, it would help if you copied & pasted the code you want to edit so that we can see what you're talking about.

    From what I've seen, in a lot of cases if Java code appears simple it's because it actually is complicated but someone else already did most of the work for you.

  • Mr_AnonymousMr_Anonymous Registered User
    edited November 2007
    Ah, a place for a lowly university programming undergrad to hang his hat at last. Janin, I salute you!

    EDIT: In fact, I have a probably very elementary question for you all I've been unable to find an answer to. It's not actual programming but very related.

    Basically, I have a Macbook Pro, bootcamped. On the windows side, I can program in java using a .jar called graphics.jar, simply by typing import graphics.*; at the top of my code. It works straight away.

    However, I'd dearly like to be able to program my stuff in OSX, because it's a pain going back and forth for this (I intended the bootcamp just for games). I cannot get the terminal compiler to recognise graphics.jar whatever I do. I have tried the classpath method as well as another I can't recall right now (2 in the morning) but neither resulted in success. I've come to the conclusion that the MANIFEST.MF file doesn't have what's needed. Graphics.jar contains several classes such as circles, rectangles, points, lines, etc. So, where do I go from here? I assume I'm being very stupid and this is exceedingly simple, as I'm struggling to find anything very clear/relevant using Google... Any help would be much appreciated.

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited November 2007
    I mean, you could just use NetBeans... I do that on OS X

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • LewishamLewisham Registered User regular
    edited November 2007

    Basically, I have a Macbook Pro, bootcamped. On the windows side, I can program in java using a .jar called graphics.jar, simply by typing import graphics.*; at the top of my code. It works straight away.

    It's a classpath issue, or it's a fucked up JAR file on your OS X partition. There is no reason why Windows is able to use a JAR file and Mac OS X doesn't.

    You could try putting the JAR into /Library/Java/Extensions to see if it's recognised when you do that. That folder is on the OS X classpath by default.

  • .:Orion.:Orion Registered User
    edited November 2007
    Shazkar Shadowstorm :

    See in your car's draw method where you draw the body?? to change the color you'd need to call g.setColor(Color); before it. You'll probably have to store the color inside the car so you can change it. You can call ShapeIcon.repaint() on your Icon control after so you see the modifications.

    Another thing. I thought .draw() didn't fill the Shape... I'm curious what your icon looks like, could you post a small image of it? :P

  • UnicronUnicron Registered User
    edited November 2007
    I'm currently working with a friend of mine who owns a games-webshop on helping him run the community side of the site (news posts etc).

    It would be a great advantage to both of us if I knew some PHP, but sadly I don't. I do however have a (very) basic knowledge of Pyhon and apprently that should help. Could anyone here recommend a book or on-line resource to help me learn PHP?

    Apologies if this has been covered here before but PHP is one letter short of the required search length.

    Thanks!

    [SIGPIC][/SIGPIC]
This discussion has been closed.