|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On January 24 2015 04:52 travis wrote:Show nested quote +On January 24 2015 04:29 Toadesstern wrote:On January 24 2015 04:16 travis wrote: I am sure this is an incredibly dumb question to be asking
but I keep looking at example java code, and the code will list that it is part of one package, and in one java file, but in the code it has more than one class
but according to netbeans every class i make has to have it's own java file? There's a difference between .java and .class files. .class files are the bytecode-files the compiler generates for the VM and like you said, that's one file per class. You probably gave me this answer because what I said didn't make sense. It wasn't really what I was asking. I figured out my problem though, I wasn't nesting the class inside the first class, I was putting it outside of it kind of, I didn't realize you're having a problem and thought you're just asking out of interest because you found 2 things on the net that you thought would be a contradiction: *I have some example java files that have more than one class per file" vs *I read somewhere that you can only have one class per file*
And like I said those two things are about 2 different things. You can have more than one class in a .java file, that's the source file you have. Your compiler however takes that and makes one .class file out of every single class you have that will be run when you actually run the program. That's what the statement you read somewhere is talking about
If you solved your issue fine. Just thought it was a general question about that.
|
Is there an easier way to do this assignment from programmingbydoing.com? (none of this is homework or anything)
The assignment is to make a "pokeswitcher". This is the code he gives you:
+ Show Spoiler + import java.util.Scanner;
public class PokeTrader { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in);
String[] pokeParty = { "PIKACHU", "CHARMELEON", "GEODUDE", "GYARADOS", "BUTTERFREE", "MANKEY" };
int x;
do { System.out.println("EXCHANGE POKEMON\n"); System.out.println("0. " + pokeParty[0]); for ( int i=1; i<pokeParty.length; i++ ) System.out.println("\t" + i + ". " + pokeParty[i]);
System.out.println("\nChoose a Pokemon to exchange with " + pokeParty[0] + ". (Or enter 0 to quit.)"); System.out.print("> "); x = keyboard.nextInt();
// add code here to swap the Pokemon in slot 0 with the Pokemon in slot x
} while ( x > 0 );
}
}
he wants you to "Write code where indicated that exchanges the Pokémon in slot 0 with the selected Pokémon. " now of course this is very easy to accomplish (these assignments mostly seem incredibly easy). but I want to know if there is a much more efficient way of doing this. anyways this is what I did (only bothered with 3 and 4)
+ Show Spoiler + public class JavaApplication31 {
public static void main(String[] args) throws FileNotFoundException { Scanner keyboard = new Scanner(System.in);
String[] pokeParty = { "PIKACHU", "CHARMELEON", "GEODUDE", "GYARADOS", "BUTTERFREE", "MANKEY" };
int x = 6; String tempPoke = "";
do { if(x>0){ System.out.println("EXCHANGE POKEMON\n"); System.out.println("0. " + pokeParty[0]); for ( int i=1; i<pokeParty.length; i++ ) System.out.println("\t" + i + ". " + pokeParty[i]);
System.out.println("\nChoose a Pokemon to exchange with " + pokeParty[0] + ". (Or enter 0 to quit.)"); System.out.print("> "); System.out.print(tempPoke); x = keyboard.nextInt(); if(x==4){ tempPoke = pokeParty[0]; pokeParty[0] = pokeParty[4]; pokeParty[4] = tempPoke; } else if(x==3){ tempPoke = pokeParty[0]; pokeParty[0] = pokeParty[3]; pokeParty[3] = tempPoke; } } // add code here to swap the Pokemon in slot 0 with the Pokemon in slot x
} while ( x > 0 ); }
}
|
First of all, remove the throw statement. You're not reading any files so you don't need to throw an exception here.
And here's what you can do (one of many ways).
pokemonToSwap = pokeParty[0]; pokeParty[0] = pokeParty[x]; pokeParty[x] = pokemonToSwap;
Don't do the if, and else-if here. Assume that you don't know how many pokemon are there and it should be irrelevant. Bonus points if you can also guard the input against entering too large a number or non-numeric character.
Edit: Also, remove the pokeParty.length from the loop and declare it outside of it.
int len = pokeParty.length;
for (int i = 1; i < len; ++i) { // do stuff }
This way you don't need to run another method with every loop pass. It's not that big of a deal, but it's a good practice to keep in mind.
|
ohhh using pokeParty[x] should have been obvious thanks dude
the throw statement i forgot to erase from another file i was writing
|
On January 24 2015 00:41 YourGoodFriend wrote:Show nested quote +On January 24 2015 00:31 Requizen wrote:On January 23 2015 09:15 Manit0u wrote:On January 23 2015 08:02 Requizen wrote: Anyone have experience working with Bootstrap and MVC? I'm trying to apply a theme that our UX team bought and I can't for the life of me get it to apply to the site. What exactly seems to be your problem? I work with Bootstrap and MVC frameworks all the time. This is my first time working with Bootstrap, I've done MVC work before. I'm using MVC 4 (for whatever reason that's what our company is using), and our UX team bought a Bootstrap template called Sugoi Admin. Every time I look up a guide to apply a Bootstrap Template to MVC, it just says "Install Bootstrap and then overwrite the CSS and JS files with the ones from the template" or something similar. But the one we bought has way more stuff inside it: The README just talks about Grunt (which I have never heard of prior to now), so I'm not really sure what to do. When I just overwrite the CSS and JS files, nothing happens on the site. So it's confusing to me. So first off bootstrap and themes are just like using any css or js in that you need to include it in your project and then reference it in your code. We just did a similar thing and to start off you need to figure out what you are using, so start with the navigation open their dummy site (usually a index.html file) and then right click and inspect element and see what classes and ids they are using to make it look that way, then start adding in those to your code. It seems a bit daunting initially but just think of it as just regular css and js that you need to reference. Hope this helps **Grunt is a command line runner used for multiple different purposes usually around minifying your css and js or linting your js
You can use grunt to compile your less/sass files to css, unify, minify and uglify them. It's pretty useful if you're not working with framework that does it for you.
Anyway, here's a nice article I've found on using bootstrap themes with MVC4 (sorry, not much experience with ASP.NET): https://www.macaw.nl/weblog/2013/5/setting-up-a-solution-with-mvc4-and-twitter-bootstrap
Skip the MVC4 installation guide and go right to setting up bootstrap themes (somewhere around the middle of the page I believe).
Here's a more detailed example: http://www.mytecbits.com/microsoft/dot-net/bootstrap-with-asp-net-mvc-4-step-by-step
All you need to do is exchange your regular bootstrap css and js with the one provided by the theme. You'll have to change the images and fonts too.
In your application you can (but don't have to) only include a single css file and a single js file (use Grunt to compile everything into a single, minified and uglified file).
|
I had one today around that level of frustrating, though not that screwed up (because few issues are that screwed up. That one isn't user-caused). It gave me 4 screens of warnings and errors. None of which made any sense and were basically GCC spewing out a bunch of complaints about templates in the boost .hpp files or other unrelated things.
Spot the issue:
typedef std::pair<int, int> Edge;
struct weight_t { typedef boost::vertex_property_tag weight; }; typedef boost::adjacency_list<boost::vecS, boost:vecS, boost::undirectedS, boost::property<weight_t, int>> Graph; typedef boost::graph_traits<Graph>::edge_iterator edgeIter;
It doesn't look so bad in a 7 line chunk, but in a 300 line file with a ton of typedefs and structs (because STL and Boost), that's not exactly the most obvious thing to spot.
|
|
woops. nice eye nesserev.
300 lines doesn't sound that bad...
|
On January 24 2015 12:54 Manit0u wrote: ... ...
This way you don't need to run another method with every loop pass. It's not that big of a deal, but it's a good practice to keep in mind.
This isn't javascript, array.length isn't a function call, it's a public final field.
|
Maybe manitou was thinking of arrayList.size ()
|
I was thinking about how this is handled in many other languages. I don't have much experience with Java.
|
On January 24 2015 05:38 Blisse wrote:Show nested quote +On January 24 2015 04:16 travis wrote: I am sure this is an incredibly dumb question to be asking
but I keep looking at example java code, and the code will list that it is part of one package, and in one java file, but in the code it has more than one class
but according to netbeans every class i make has to have it's own java file? In Java I believe you can have multiple classes inside a java file, but only the first class will be public to other files, so all the rest of the classes are private to the file. I'm a shitty Java developer so I might be wrong. In Java you can have multiple classes per file which are visible. See "inner classes"
http://docs.oracle.com/javase/tutorial/java/javaOO/innerclasses.html
An inner class can be public or private (or package private). It can be static or not-static too:
http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class
Typical usages for a publicly visible static inner class might be things like Factories, enums that are really only relevant to the outer class, etc.
You may come across a lot of private (not-visible) inner classes as part of implementation for a more public interface. For many examples of that see the collections library in guava:
https://github.com/google/guava/blob/master/guava/src/com/google/common/collect/ImmutableList.java
|
On January 24 2015 15:26 Nesserev wrote:Show nested quote +On January 24 2015 14:43 Ben... wrote:I had one today around that level of frustrating, though not that screwed up (because few issues are that screwed up. That one isn't user-caused). It gave me 4 screens of warnings and errors. None of which made any sense and were basically GCC spewing out a bunch of complaints about templates in the boost .hpp files or other unrelated things. Spot the issue: typedef std::pair<int, int> Edge;
struct weight_t { typedef boost::vertex_property_tag weight; }; typedef boost::adjacency_list<boost::vecS, boost:vecS, boost::undirectedS, boost::property<weight_t, int>> Graph; typedef boost::graph_traits<Graph>::edge_iterator edgeIter;
It doesn't look so bad in a 7 line chunk, but in a 300 line file with a ton of typedefs and structs (because STL and Boost), that's not exactly the most obvious thing to spot. Do you mean the malformed scope operator, or ... ? Normally such error messages are really simple, so I guess it's not that, but I guess that because Graph isn't declared then, any other definitions using Graph fail barf errors too. It is exactly that. One tiny typo cascading into over 80 lines of errors and warnings. Yes, normally scope operators are easy error messages but the thing I'm working on has to be portable to Linux, Windows, and OS X so I'm just using vim and make for it so spotting that type of thing is not exactly easy thanks to no error highlighting. So yes, at least one error for every operation I did on the typedefed Graph, with a simple "hey this typedef is busted because of a borked scope operator" error buried in a mess of other similar looking "hey this typedef is busted too" errors somewhere. Not to mention the wonderful template errors like "error: int is not a class, struct, or union type" (caused by GCC thinking Graph is supposed to be an int since the typedef failed) or "error: here's this entire template structure. Something went wrong in our type deduction but we won't tell you what's wrong but look at this wonderful structure!" (these are also caused by GCC thinking Graph is an int).
This is what I get for doing everything manually with a makefile rather than doing a quick cmake file and allowing myself the ability to port my project to the IDEs of various OSes quickly. We have to use cmake in one of my other classes and I've grown to like it quite a bit. It placates the militant Visual Studio people while allowing us linux people to do our own thing too. Much better than forcing everyone onto one IDE or one way of doing things.
|
i know im prolly just getting ahead of myself but i want to ask anyways
let's say I have a jframe and then I also have a jpanel
the jframe adds the jpanel and uses (pack) to match the dimensions of the jpanel
the jframe also adds a mouselistener to do stuff on clicks
ok so that sets the scene
now, i add components to the JPanel. Maybe a button and a textpane but now, my mouselistener stops working if I try to click on the areas where those components are. I don't want it to stop working, I want it to apply to everything that is in the jframe
how do I fix this
i am guessing I need to add some sort of global mouse listener
|
|
On January 26 2015 01:26 Nesserev wrote:I'm currently working on updating/upgrading my resume/cv, so that I can apply for summer internships at some companies, including google. There's one part of my resume that has been keeping me busy for the past couple of hours. Normally, people tend to list all the languages that they're familiar with, eg: Programming Languages: C, C++, C#, CSS, Java, JavaScript, Perl, PHP, PL/SQL, Python, SQL, Visual Basic 6, Visual Basic .NET, Visual Basic for Applications, XHTML, XSLT, XML Databases: Microsoft SQL Server, MySQL, Oracle 9i through 11g Frameworks: ASP.NET, ASP.NET MVC, jQuery, jQuery UI
+ Show Spoiler +Lol, I just plucked this list from the internet somewhere... half the list of things under programming languages isn't even a programming language. RIP random guy... But I decided to list my preferred languages (I explain the reasons further down below) Preferred Languages C++, Python, Haskell
I showed my senpai my cv/resume, and he told me to do as everyone else, and list all the languages that I'm familiar with. So, here's my explanation about why I prefer using preferred languages... still waiting for him to bestow me with his knowledge though. Show nested quote +I thought a lot about that 'preferred languages' part, and I kinda like the notion of it, but I'm not very sure about it. Here's my train of thoughts:
I feel like it shows more personality to list my preferred languages. I could probably pick up any language in a reasonable amount of time, as expected of me. If they want me to work with C, no problem, Fortran, I won't complain. Only in the case of Java, will I look for another company (jk). Which programming language you use, is just a small part of the job... most skills are transitive between languages, right?
In that sense, a list of languages that I've used in the past doesn't add that much value, and kinda clutters everything without giving any extra relevant information about who I am. Maybe I should make an extra separate list of all other languages that I'm familiar with, just because it's kinda expected.
I hope that 'preferred languages' also triggers the question "Why did you only list your preferred languages? Do you know how to C#?", to which I feel, the first paragraph above is a strong answer, and shows a good mindset. There is no elegant way to write on your resume: "just give me a language and a bunch of tools, I'll make it work, no problemo".
On the other hand, I won't be there when they read my resume for the first time. It puts the reader of the resume in the dark, and perhaps triggers the idea that I don't know anything else, and that my knowledge is limited to the programming languages I listed. So, what would you guys recommend doing? List all languages that I'm familiar with? Do you guys like the idea of just showing preferred languages, etc?
I personally would list languages that meet the following criteria: it is applicable to the job/internship that you are applying for and you are prepared to answer questions on it. In my opinion listing a language shows a moderate degree of proficiency, hopefully more so than you used it for a day or two. While I agree that you don't want to seem under qualified, I know I've been very disappointed interviewing people who have listed php or javascript frameworks on their resume (while interviewing for our java shop) and have been unable to answer moderate skill level questions about them.
|
On January 25 2015 05:44 travis wrote: i know im prolly just getting ahead of myself but i want to ask anyways
let's say I have a jframe and then I also have a jpanel
the jframe adds the jpanel and uses (pack) to match the dimensions of the jpanel
the jframe also adds a mouselistener to do stuff on clicks
ok so that sets the scene
now, i add components to the JPanel. Maybe a button and a textpane but now, my mouselistener stops working if I try to click on the areas where those components are. I don't want it to stop working, I want it to apply to everything that is in the jframe
how do I fix this
i am guessing I need to add some sort of global mouse listener Eh not that familiar with graphics stuff in java but I suppose you could give your panels a mouselistner that just calls the mouselistner of the Jframe?
|
On January 26 2015 01:26 Nesserev wrote:I'm currently working on updating/upgrading my resume/cv, so that I can apply for summer internships at some companies, including google. There's one part of my resume that has been keeping me busy for the past couple of hours. Normally, people tend to list all the languages that they're familiar with, eg: Programming Languages: C, C++, C#, CSS, Java, JavaScript, Perl, PHP, PL/SQL, Python, SQL, Visual Basic 6, Visual Basic .NET, Visual Basic for Applications, XHTML, XSLT, XML Databases: Microsoft SQL Server, MySQL, Oracle 9i through 11g Frameworks: ASP.NET, ASP.NET MVC, jQuery, jQuery UI
+ Show Spoiler +Lol, I just plucked this list from the internet somewhere... half the list of things under programming languages isn't even a programming language. RIP random guy... But I decided to list my preferred languages (I explain the reasons further down below) Preferred Languages C++, Python, Haskell
I showed my senpai my cv/resume, and he told me to do as everyone else, and list all the languages that I'm familiar with. So, here's my explanation about why I prefer using preferred languages... still waiting for him to bestow me with his knowledge though. Show nested quote +I thought a lot about that 'preferred languages' part, and I kinda like the notion of it, but I'm not very sure about it. Here's my train of thoughts:
I feel like it shows more personality to list my preferred languages. I could probably pick up any language in a reasonable amount of time, as expected of me. If they want me to work with C, no problem, Fortran, I won't complain. Only in the case of Java, will I look for another company (jk). Which programming language you use, is just a small part of the job... most skills are transitive between languages, right?
In that sense, a list of languages that I've used in the past doesn't add that much value, and kinda clutters everything without giving any extra relevant information about who I am. Maybe I should make an extra separate list of all other languages that I'm familiar with, just because it's kinda expected.
I hope that 'preferred languages' also triggers the question "Why did you only list your preferred languages? Do you know how to C#?", to which I feel, the first paragraph above is a strong answer, and shows a good mindset. There is no elegant way to write on your resume: "just give me a language and a bunch of tools, I'll make it work, no problemo".
On the other hand, I won't be there when they read my resume for the first time. It puts the reader of the resume in the dark, and perhaps triggers the idea that I don't know anything else, and that my knowledge is limited to the programming languages I listed. So, what would you guys recommend doing? List all languages that I'm familiar with? Do you guys like the idea of just showing preferred languages, etc?
For the recruiter only one thing matters: Does the person have the languages he needs for the job listed in his CV. However, for the actual technical expert that is recruiting people it's important to know how familiar you are with any language since the programming field changes fast and knowing many languages means that you can learn new technologies fast. It might also mean that, even if you don't get the job you applied for, your CV might get forwarded to some other department in the company where they need someone who knows X. Basically, always write everything you know unless you really, really don't want anything to do with X.
I use three categories: Languages I'm fluent with and could start a job using them by tomorrow, languages I'm rusty with and would need to do some catching up but can be productive with them by monday next week and languages I'm familiar with but haven't learned them in depth, i.e. languages I can read and understand but would need to put in a few days to become productive in them.
For example in my case: Programming languages: - Fluent: C, C#, PHP, JavaScript, PL/SQL - Rusty: C++, Java, Perl, Delphi - Familiar: Scheme, VB, Python
|
Two general things:
1) Err on the side of putting down less, because being concise is good in this situation. Keep in mind that the people reading your resume (recruiters, interviewers, hiring committees, etc) are reading a LOT of resumes. If your resume is longer than 3/4 of a page for an internship, it is probably too long.
2) Don't write things down that you aren't actually comfortable using (unless you qualify with a phrase like "passing familiarity in ..."). Some interviewers will think it fair game to ask you questions about things you put on your resume, which might include awkwardness if it turns out you aren't actually very good at some language you've written.
On January 26 2015 01:26 Nesserev wrote:But I decided to list my preferred languages (I explain the reasons further down below) Preferred Languages C++, Python, Haskell
I would prefer this format.
If you are specifically looking at Google (or elsewhere honestly, still good tips) look at these (though bear in mind they may be geared towards full time, not internship):
https://www.linkedin.com/pulse/20140929001534-24454816-my-personal-formula-for-a-better-resume https://www.linkedin.com/pulse/20140917045901-24454816-the-5-biggest-mistakes-i-see-on-resumes-and-how-to-correct-them
Also bear in mind that Google doesn't really do Haskell, so might not be relevant (could leave on, but don't expect to do an interview in Haskell).
Also consider applying soon for big companies; many of them have already started allocation for admitted interns in the late fall / early winter.
|
Also if you have less than 10 years experience you shouldn't have more than 1 page on your resume.
I don't have enough long term experiences with other languages so I just list my 3 main, C#, C++, Python if I do list them. I've tended to drop my "skills summary" section though and just focus on having cooler, better descriptions of my jobs and projects.
|
|
|
|