Open Side Menu Go to the Top
Register
Programming homework and newbie help thread Programming homework and newbie help thread

08-04-2015 , 02:39 AM
Concurrency Question


I'm creating a Multi-player Blackjack game in java and am creating a Singleton class 'TableCreator' that opens tables and seats players. I'm writing an atomic method addPlayer(Player p) that will first check for tables with free seats by invoking boolean method hasFreeSeat() on each table.

does method hasFreeSeat() need to be synchronised aswell?



My noob thoughts: I think not as TableCreator is a Singleton class and method addPlayer() is atomic so hasFreeSeat() cannot be invoked simultaneously.

Appreciate any input on this
Programming homework and newbie help thread Quote
08-04-2015 , 03:41 AM
Quote:
Originally Posted by CyberShark93
Hi friends!
quick question,
i'm required to convert a simple fortran program to C most of it is straight forward, but i've never done fortran before and I saw this line:

PARAMETER( SCALE=2.**8 );

and I was wondering what it does, and whats the C equivalent of this.
** is exponentiation in Fortran http://www.obliquity.com/computer/fortran/operate.html

In C you need the pow function
http://stackoverflow.com/questions/2...entiation-in-c
Programming homework and newbie help thread Quote
08-08-2015 , 01:14 AM
Java App - Blocked by security

I'm trying to locally execute an app using Java WebStart however I keep getting the 'Application Blocked by Java Security' dialog box.

I've added the following location to the 'Exception Site List' but still keep getting blocked.

'file:/C:/Users/****/Documents/************/*****/******/BlackjackText/dist/launch.html'

Any ideas what could be going wrong? Thanks
Programming homework and newbie help thread Quote
08-08-2015 , 12:05 PM
Quote:
Originally Posted by dummy101
Java App - Blocked by security

I'm trying to locally execute an app using Java WebStart however I keep getting the 'Application Blocked by Java Security' dialog box.

I've added the following location to the 'Exception Site List' but still keep getting blocked.

'file:/C:/Users/****/Documents/************/*****/******/BlackjackText/dist/launch.html'

Any ideas what could be going wrong? Thanks
Tried struggling with Java security permissions from an administrative stand point for ages and got nowhere. There is a security file you can modify but I never got it to work with our application.

Not a Java expert but from what I could gather the application may have to provide it's own security file to execute properly in newer versions of Java. It's been awhile since I've read the documentation for it though.
Programming homework and newbie help thread Quote
08-27-2015 , 05:07 PM
I'm learning C++ in one of my classes, any advice on what IDE to use? The instructor recommended just using visual studio, but from what limited things I know it just sounds like total AIDS, and it sounded like it was just out of laziness that he recommended it ("well get this because lots of people use it and I haven't really written any code since 1988 so I have no idea what is good").
Programming homework and newbie help thread Quote
08-27-2015 , 05:19 PM
Eclipse works just fine.
Programming homework and newbie help thread Quote
08-27-2015 , 05:33 PM
Quote:
Originally Posted by Alobar
I'm learning C++ in one of my classes, any advice on what IDE to use? The instructor recommended just using visual studio, but from what limited things I know it just sounds like total AIDS, and it sounded like it was just out of laziness that he recommended it ("well get this because lots of people use it and I haven't really written any code since 1988 so I have no idea what is good").
Microsoft can do one thing right and that is make an IDE.

Visual Studio 2015 Community edition is really nice and free.
It has all the features of what the Pro edition used to have and was pretty expensive if you didn't get it by being a student or pirating it.

I honestly believe that for C++, Visual Studio is better than Eclipse and you should go with Visual Studio.
Another alternative is Clion made by Jetbrains but it isn't free and I would not advice a beginner to C++ to use Clion vs Visual Studio.

I'm a fan of eclipse, i've used to for Android development and Java with testing out the C++ version.
You probably could pick whichever IDE (Eclipse or VS) but I bet you would like Visual Studio with Dark Theme vs Eclipse dark theme.
Programming homework and newbie help thread Quote
08-27-2015 , 06:48 PM
Quote:
Originally Posted by Alobar
I'm learning C++ in one of my classes, any advice on what IDE to use?
Have you used any other IDEs for other languages before?
Programming homework and newbie help thread Quote
08-27-2015 , 07:06 PM
Quote:
Originally Posted by Alobar
I'm learning C++ in one of my classes, any advice on what IDE to use? The instructor recommended just using visual studio, but from what limited things I know it just sounds like total AIDS, and it sounded like it was just out of laziness that he recommended it ("well get this because lots of people use it and I haven't really written any code since 1988 so I have no idea what is good").
I agree with iosys but I guess I should ask what the compiler you are using is.
Programming homework and newbie help thread Quote
08-27-2015 , 07:36 PM
If you are just learning C++, Clion might actually be not that bad and feel lightweight compared to Visual Studio.

Yet, I don't think it is best for someone new; dealing with CMakeLists.txt but you probably wouldn't touch that much besides adding source and header files.
It takes a small learning curve to figure out, how to include packages with CMakeLists.txt but you probably wouldn't be doing that when learning C++.

Probably will be just learning syntax, recursion, linked lists and sorting.

I love using Clion more than Visual Studio.
There is a free trial for Clion if you're curious on checking it out.
Programming homework and newbie help thread Quote
08-27-2015 , 08:21 PM
Quote:
Originally Posted by Low Key
Have you used any other IDEs for other languages before?
I use eclipse for Java and used it for android before android studio came out. That's the only IDE ive ever used tho



I guess I will have to give VS a try
Programming homework and newbie help thread Quote
09-01-2015 , 06:40 AM
It might be the old guy in me talking but I never understood why beginners aren't taught how to build c++ code using the basic editor+compiler first.

Sure, an IDE offers lots of benefits for power users but I feel like it's helpful for people to get a basic understanding of the process of going from code in a plain text file to compiled binary rather than just typing some code and then pressing the magic "compile&run" button.
Programming homework and newbie help thread Quote
09-01-2015 , 07:11 PM
I agree with Wolfram. There's some big merit learning how to compile stuff from scratch. I had to work on a project the past summer where I had difficulty compiling some programs from source. I never understood what makefiles were and I only learned from school that you can compile stuff magically from visual studio. So once I had to compile something from source, something that is supposed to be trivial, proved difficult for me.
Programming homework and newbie help thread Quote
09-01-2015 , 08:10 PM
People have it so easy today with their remote start cars. They should have to manually crank the engine to get it started like we did before automatic starters!

No, this isn't a perfect analogy, but it's pretty close.

I don't think I gained anything by knowing how to compile stuff manually in my first c++ course back in the early oughts.
Programming homework and newbie help thread Quote
09-01-2015 , 08:21 PM
Quote:
Originally Posted by Low Key
People have it so easy today with their remote start cars. They should have to manually crank the engine to get it started like we did before automatic starters!

No, this isn't a perfect analogy, but it's pretty close.

I don't think I gained anything by knowing how to compile stuff manually in my first c++ course back in the early oughts.
Eclipse will actually create a make file for C++ projects. That is a good model for make files. I knew the basics of make files but every time I looked at one it was completely cryptic. Then when I read the GNU manual on make files I understood why. There are so many implicit commands and parameters if you don't know them you will have a problem in reading them. Personally I'd rather just have a straightforward make file with explicit commands. I have also done a fair amount of looking at relocatable object files in various formats and have actually written an assembler. With all that I agree with LowKey pretty much, I don't see that much value.

Perhaps being able to configure a product build for something like Jenkins would be valuable and I fully admit that if you do something that breaks a product build then it is helpful to know how the build system is put together if for no other reason to point the finger in another direction if you weren't responsible. Yes this has happened to me in the past.
Programming homework and newbie help thread Quote
09-01-2015 , 09:41 PM
It's definitely not past the point of being useful at all (as opposed to the car crank example), and maybe it never will be. But from an outsider's perspective it seems almost functionally useless.

Good to know about, and to know what's happening behind the scenes of your IDE. But other than that...
Programming homework and newbie help thread Quote
09-02-2015 , 12:50 AM
Compilers? LUXURY! Back in my day we manually converted our C++ code to machine language using rules we had to look up in an enormous leather-bound book. If you haven't gone through that process you'll never learn what goes on behind the scenes.

Quote:
Originally Posted by Wolfram
It might be the old guy in me talking but I never understood why beginners aren't taught how to build c++ code using the basic editor+compiler first.

Sure, an IDE offers lots of benefits for power users but I feel like it's helpful for people to get a basic understanding of the process of going from code in a plain text file to compiled binary rather than just typing some code and then pressing the magic "compile&run" button.
So instead of hitting the magic "compile and run" button they gain a deeper understanding of compilation.... by using the magic "gcc" command instead? Confused about how editing in Notepad and entering a command to compile is any more edifying a process than editing in an IDE and hitting a button to compile.
Programming homework and newbie help thread Quote
09-02-2015 , 01:13 AM
You guys bring up good points. Thinking it over, I think the problem more lies with the teacher. Some students aren't even aware of what goes behind the IDE. For most students, they think the IDE is the only way to compile a program, which I think is the problem.

I still think it's good to show them at least once, so at least they are aware.


http://jangosteve.com/post/380926251...t-theyre-doing
Programming homework and newbie help thread Quote
09-02-2015 , 05:58 AM
Whoa, didn't realize I was igniting a religious war

I just feel like most beginners won't even realize that editing the code and then compiling it are independent tasks. To them the IDE is this big black box that does everything and they have no idea how.

I'm not saying schools should force people to do every project like this. I'm talking about teaching people how stuff works. It's analogous to teaching cs101 students how to make their own linked lists. Outside the classroom you will probably never have to do it but it helps to build a foundation of understanding data structures.

Quote:
Originally Posted by Low Key
People have it so easy today with their remote start cars. They should have to manually crank the engine to get it started like we did before automatic starters!

No, this isn't a perfect analogy, but it's pretty close.
Your analogy assumes a users perspective only. Of course it's easier for a user to use a more advanced product. But programmers have the engineers perspective and to continue your analogy it's fine for them to learn how early engines were started before electric starters were introduced. Especially when some modern cars still don't use automatic starters (not every language has an IDE).

Quote:
I don't think I gained anything by knowing how to compile stuff manually in my first c++ course back in the early oughts.
That's cause you learned it the right way round the first time

I learned the IDE way first and struggled when I was had to use non-IDE tools outside the classroom.

Last edited by Wolfram; 09-02-2015 at 06:15 AM.
Programming homework and newbie help thread Quote
09-02-2015 , 06:51 AM
@wolfram - Except that "managed code" environments don't really have the same process as C/C++ code does for actually building and running executables. Then we have languages like Python that are different from those.

Your point is well taken by me. However, I think what this will devolve into is how does a processor actually work. I mean that is the common denominator in the three build and execute models I mentioned. I work very close to the processor architecture as my current assignment is basically developing assembly language code. I recognize though that people work in the more abstract environments because they are more productive software product wise. Learning some of this in school is ok I guess but working in the "real world" doesn't really require that knowledge very often and focusing on more abstract programming topics in lieu of understanding low level, close to the hardware activities is certainly justifiable in my view.
Programming homework and newbie help thread Quote
09-02-2015 , 07:32 AM
fair enough
Programming homework and newbie help thread Quote
09-02-2015 , 08:30 AM
I have a teacher, every time he goes to run code always says, "compile and run it," which you might think is unnecessary, but people have tried turning compiled code in for assignments. Not the easiest thing to read, I hear.
Programming homework and newbie help thread Quote
09-03-2015 , 08:50 AM
Hey guys, Im having a problem storing a hashed password on a mySQL database.

Im using SHA-256 and storing a 32-byte hash in a column of type CHAR(64) but when I retrieving the same hash using the following code, it returns a different 11-byte hash.

ResultSet rs;
rs = st.executeQuery("SELECT * FROM customer_accounts WHERE nickname='" + nickname + "'");
rs.next();
byte[] h = rs.getBytes("passhash");

out.println("HashAfter: " + Arrays.toString(h) + " SaltAfter: " + Arrays.toString(s));

Any ideas what I could be doing wrong here? Thanks
Programming homework and newbie help thread Quote
09-03-2015 , 03:33 PM
Quote:
Originally Posted by gaming_mouse
Thanks for the link gaming_mouse, I'll look into implementing bcrypt.

I would still like to know why my 32-byte hash returns as a different 11-byte hash after being stored and retrieved from a database.

Any ideas?
Programming homework and newbie help thread Quote

      
m