Jacob Steingart

Ranch Hand
+ Follow
since Mar 28, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jacob Steingart

Wow, I feel silly. I tend to overthink things, as I'm sure you noticed. I'm coming back to programming after a very long hiatus, so I'm rusty, on both the language itself (syntax, etc) and also general design and logic. I feel stupid... Anyway, I created a static BufferedWriter, instantiated it in a method that I'm using to set things up for the bulk of the program and then closed it right before the program ends. Paul, I'm sorry that I made you answer a pretty obvious question. But now I know that, when faced with a challenge, I need to step back and find the simplest and most efficient way to solve a problem. Thank you for pointing me in the right direction!
12 years ago
Hello everyone,
I'm a bit stuck right now. I'm going to have a program that will be taking dynamically created Strings (in the case of this test, the input taken from a BufferedReader using readLine()), and write them to a text file. It's essentially a log. The simplest way to do this would probably be to have a static FileWriter and pass the String to a method that would write it to a text file and then close the connection. This would be easy, but it seems inefficient because you would have to write and close for every String. My first idea was to have a separate thread that would do the writing so it wouldn't have to close the connection all the time. The trouble is that I can't figure out how it is possible to pass each String to the method that is writing to the file. Or am I on the wrong track entirely? I feel like this should be basic, but I just can't seem to figure it out . All help is appreciated!

P.S. I put this in the "I/O and Streams" forum, but I wasn't sure if it should go in the "Threads and Synchronization" forum. I figured it should go here considering that the solution may or may not revolve around threading.
12 years ago
Yeah, now I'm starting to realize how little I have to go on. Thanks for your help, anyway! I'll try to contact him.
Hi everyone,
I have a friend who is a computer science major and was telling me about a project he did in his networking class. He was making a peer-to-peer (sort of... he didn't have a very in-depth explanation; he said it was "fake" peer-to-peer, whatever that is supposed to mean) chat client. He was telling me about something called CAT (or maybe it was CATS?) that he used in it. I'm not sure what exactly he was talking about, and I can't find any information on the internet. He wrote the program in Java. Is it some sort of protocol? The only things I can find that are related to networking and have CAT in them are cables. Any help would be appreciated! Thanks in advance. Sorry for the newbie question.

Jacob
Where can I find out how many decimal places a float and double can hold? I tried Googling it, but not much came up. Also, I think I saw something about putting the letter f after the number when you are assigning a value to a float, and I'm not sure how to put that in when you are doing math. For example:

float blah = 12.084f;
vs:
float blah = i/24;
13 years ago
Yeah, sorry, I suppose it wasn't clear. The only reason I put the variable type as int was because I wasn't sure what having an array of floats would look like. I don't want to use a double because I could be working with a really big number with a lot of decimal places, and that would eat up a lot of memory. Do you sort of understand what I was saying? It's hard to communicate these things in just forum posts. At least for me T_T.
13 years ago
Hello everyone,
I'm currently making a program to calculate the value of pi, I believe using Simpson's Rule. I'm very new to the math and am still trying to get everything straight in my head, but I understand enough that I can start to work on some of the programming logistics of it. I'm basing a lot of this off of information from here.

Anyways, right now I'm essentially trying to divide 1 into a given number of divisions. The user is actually putting in a number of data points that will be created by dividing 1 by a certain number, which is the number of data points minus 1. For example, in order to get 5 data points, you would have to divide 1 by 4. You'd get 0, .25, .5, .75, and 1 as data points. I'm storing these data points in an array. I think I will create a separate value for the number of divisions as to avoid even more math when assigning the values of the data points to variables in the array. I'm getting these values through a for loop. The basic idea is something like this:


Now this would be all fine and dandy if it weren't for the fact that I want to use a float, not an int. I've never really worked with floats, but I'm pretty sure you have to tag an "f" on to the end of the number you are assigning it. I guess my main question is this: how do you assign a float type variable a value based off of another variable? I feel kind of stupid for asking it, but I guess I've just never really worked with floating point numbers in Java '~'. Thanks in advance!

Jacob>
13 years ago
Unfortunately no. I'm trying to figure out the mystical numbers that ShortMessage's setMessage method use to set things like the instrument and the note played. I figure that 71 is a B (I don't have full perfect pitch, but I can recognize Bs), and that the notes increase by half steps for each number, but I don't know if there is a cheatsheet I could use to just look up the note I might want.

Ironically, I'm writing this software for two reasons, one just being to familiarize myself with the javax.sound.midi package, the other to write software to help me work on perfect pitch and ear training, yet I'm using my small amount of perfect pitch to write the software to help my perfect pitch!
15 years ago
Does anyone know where I could find a list of what numbers different notes and instruments are? Thanks in advance.
15 years ago
So you essentially make an ArrayList of Lists, and then assign your values to the list. Now that I think of it, I could probably just make an ArrayList of Arrays- I'm storing data in this, and I have a fixed number of columns, but a variable number of rows. Could you do this by saying something like



I believe I have usable code!
15 years ago
Not to be 'that guy', but stuff like this really annoys me. Why are you using Java3D if you are just going to do the smallest amount of code possible? If you want to make a game, etc. that doesn't require much coding, take a look at Blender or something. I am very much a purist when it comes to coding. I write or modify most software I use. I realize that it isn't always possible to do everything yourself and by hand, but saying something like "Do we really need to code to use Java3D?" is like asking "Do we need to code in order to code?" Sorry for being annoying, I'm sure I was ;). As I said before, these things annoy me.
15 years ago
Is it possible to make a three dimensional ArrayList?
15 years ago
Hey everyone,
I'm writing some software to (attempt) to help me organize/catalog my home library, and I'm trying to make it so I can dynamically add books to a big JTable of them and info about them. What I want to do is have an ArrayList (or other dynamic array-esque thing) that contains a bunch of Book objects. Each Book will have instance variables such as a title, author, ISBN, etc. How can I make a table/table model that will display this data.

-GUI Newbie
15 years ago
Aha, I'm starting to see how this works. Which version do you suggest? 6.x?
15 years ago
JSP
Ahh, I see. Thanks.
15 years ago