+ Show Spoiler +
![[image loading]](http://i.imgur.com/uQDnHaT.jpg)
edit: im dumb. its background-repeat
| Forum Index > General Forum |
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. | ||
|
icystorage
Jollibee19350 Posts
+ Show Spoiler + ![]() edit: im dumb. its background-repeat | ||
|
berated-
United States1134 Posts
On January 27 2014 13:47 WarSame wrote: Hey everyone, could someone point me to a good guide on the basics of Java sounds? I want to make a program that is a simple timer that beeps at the end. However, none of the guides I have found online have been near useful. In particular, the current one works according to Eclipse, but when it tries to load the file in as an AudioInputStream it has a heart attack and dies. So any help/pointers on getting started would be nice. For example, if someone has done this in the past if you could just post the basic code of how to get a sound playing from on file that would make me a happy coder. Thanks. Here is what I have so far: public Timer() {It points out a Null pointer exception from the variable url(which I've printed separately and it seems to actually be null). However, every post I've seen elsewhere online has it like this, and I actually got this code from somewhere else, so I'm pretty confused about what went wrong. It's likely something with the file location but I print that as well and it looks fine. So I'm scratching my head. I don't know anything about java audio, but luckily I don't think that's your problem. You are trying to load a classpath resource with a file path, which isn't the same thing. You either need to switch over to learning how loading resources from a classloader works, or just use the file based method on AudioSystem. File based:
I can't see your classpath, but I would guess if your .mid file is in your java path, you could just do
| ||
|
actionbastrd
Congo598 Posts
Prompt the user and accept the following types of values from a SINGLE input line: char float int char. What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D: This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything! + Show Spoiler + char f, g; int h; float i; printf("Enter a char, float, int, char; with no spaces in between each input: "); scanf("%c%f%d%c", &f, &i, &h, &g); printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g); | ||
|
Tobberoth
Sweden6375 Posts
On January 27 2014 21:28 actionbastrd wrote: So i am trying to learn C programing, and am hoping to dive really deep into it. I have a task which i am having trouble with. I feel like accomplishing this task could be done way better, but none the less, Prompt the user and accept the following types of values from a SINGLE input line: char float int char. What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D: This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything! + Show Spoiler + char f, g; int h; float i; printf("Enter a char, float, int, char; with no spaces in between each input: "); scanf("%c%f%d%c", &f, &i, &h, &g); printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g); You could just write a loop and use getchar, parse the input yourself. Scanf is kind of dangerous to use anyway because it's fairly weak against buffer overflow exploits (not that you should worry about such things when you're beginning, but still). Writing your own parser will probably teach you a lot more than just learning the format of scanf. | ||
|
WarSame
Canada1950 Posts
On January 27 2014 21:21 berated- wrote: Show nested quote + On January 27 2014 13:47 WarSame wrote: Hey everyone, could someone point me to a good guide on the basics of Java sounds? I want to make a program that is a simple timer that beeps at the end. However, none of the guides I have found online have been near useful. In particular, the current one works according to Eclipse, but when it tries to load the file in as an AudioInputStream it has a heart attack and dies. So any help/pointers on getting started would be nice. For example, if someone has done this in the past if you could just post the basic code of how to get a sound playing from on file that would make me a happy coder. Thanks. Here is what I have so far: public Timer() {It points out a Null pointer exception from the variable url(which I've printed separately and it seems to actually be null). However, every post I've seen elsewhere online has it like this, and I actually got this code from somewhere else, so I'm pretty confused about what went wrong. It's likely something with the file location but I print that as well and it looks fine. So I'm scratching my head. I don't know anything about java audio, but luckily I don't think that's your problem. You are trying to load a classpath resource with a file path, which isn't the same thing. You either need to switch over to learning how loading resources from a classloader works, or just use the file based method on AudioSystem. File based:
I can't see your classpath, but I would guess if your .mid file is in your java path, you could just do
It works. Thanks a lot! | ||
|
phar
United States1080 Posts
On January 27 2014 21:32 Tobberoth wrote: Show nested quote + On January 27 2014 21:28 actionbastrd wrote: So i am trying to learn C programing, and am hoping to dive really deep into it. I have a task which i am having trouble with. I feel like accomplishing this task could be done way better, but none the less, Prompt the user and accept the following types of values from a SINGLE input line: char float int char. What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D: This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything! + Show Spoiler + char f, g; int h; float i; printf("Enter a char, float, int, char; with no spaces in between each input: "); scanf("%c%f%d%c", &f, &i, &h, &g); printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g); You could just write a loop and use getchar, parse the input yourself. Scanf is kind of dangerous to use anyway because it's fairly weak against buffer overflow exploits (not that you should worry about such things when you're beginning, but still). Writing your own parser will probably teach you a lot more than just learning the format of scanf. Scanf is technically safe if you are careful about how you construct your calls to it. In particular, never use %s, always use %99s (for example, if putting into a char[] of 100). But that gets annoying in many situations, so fgets, getchar, etc etc may be nicer. Also check the return value! Good habit to get into. | ||
|
Blisse
Canada3710 Posts
| ||
|
Garfailed
Netherlands409 Posts
On January 26 2014 22:07 Manit0u wrote: Show nested quote + On January 26 2014 15:53 Housemd wrote: Update on Program: int array [] = {15, 26, 27, 74, 65, 36, 73, 46, 73, 29, 30}; Scanner scan = new Scanner (System.in); boolean x = true; System.out.print("Please input a number"); int SearchValue = scan.nextInt(); for (int i = 0; i < array.length; i++){ if (x == true){ SearchValue = array [i]; break; } } if (x){ System.out.println("Found"); } else { System.out.println("Not Found"); } } } Works perfectly fine for values that are in the array. For values that are not, it still prints out found. I believe that I have a small syntax error (in the last if-else statement?) but I cannot spot it. I tried to use Chocolate's suggestions of booleans and it looks promising. Why use for loop here instead of foreach?
Instead of printing at every index of the array, you could have a boolean. Set it to false before you loop, and if (n == searchvalue) set it to true, then at the end check if (found) is true or false and print accordingly | ||
|
nunez
Norway4003 Posts
On January 28 2014 14:35 Blisse wrote: writing an operating system on an arm board... oh god the void* ah sweet! more descriptive please! | ||
|
Badboyrune
Sweden2247 Posts
However when I enable "getActionBar().setDisplayHomeAsUpEnabled(true);" and try to navigate backwards with the Home button that breaks any activity that relies on receiving an intent, because it doesn't receive any. I tried putting the information in the onSaveInstanceState bundle, but the activity does not receive the bundle when navigated to with the Home button (savedInstanceState != null returns false). I've looked through all I've been able to find online (which has been limited because searches involving android home button are generally unhelpful) and all I've really been able to find is that the home button seems to not be programmable anymore, it either sends you to the app home activity, or the activities parent activity which is what I'm trying to achieve. I'm assuming there's some way of doing this so any help would be much appreciated. | ||
|
Manit0u
Poland17491 Posts
On January 27 2014 21:32 Tobberoth wrote: Show nested quote + On January 27 2014 21:28 actionbastrd wrote: So i am trying to learn C programing, and am hoping to dive really deep into it. I have a task which i am having trouble with. I feel like accomplishing this task could be done way better, but none the less, Prompt the user and accept the following types of values from a SINGLE input line: char float int char. What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D: This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything! + Show Spoiler + char f, g; int h; float i; printf("Enter a char, float, int, char; with no spaces in between each input: "); scanf("%c%f%d%c", &f, &i, &h, &g); printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g); You could just write a loop and use getchar, parse the input yourself. Scanf is kind of dangerous to use anyway because it's fairly weak against buffer overflow exploits (not that you should worry about such things when you're beginning, but still). Writing your own parser will probably teach you a lot more than just learning the format of scanf. When dealing with different data types in input you want to be using sscanf instead of scanf in C: http://forum.codecall.net/topic/73122-on-using-sscanf/ http://en.cppreference.com/w/c/io/fscanf (at the very bottom here you have an example similar to what you're trying to do) There you go:
Edit: A bonus with using sscanf is also that it doesn't matter if someone will enter the input with or without spaces. It doesn't matter. | ||
|
berated-
United States1134 Posts
On January 29 2014 09:01 Badboyrune wrote: Ok I'm getting quite confused. I'm making a pretty basic android app, it's my first so my experience is very limited. It basically displays data from a database based on intent sent from the intent sent from another activity in the app. This all worked fine, I could navigate without any issue with the android OS back button. However when I enable "getActionBar().setDisplayHomeAsUpEnabled(true);" and try to navigate backwards with the Home button that breaks any activity that relies on receiving an intent, because it doesn't receive any. I tried putting the information in the onSaveInstanceState bundle, but the activity does not receive the bundle when navigated to with the Home button (savedInstanceState != null returns false). I've looked through all I've been able to find online (which has been limited because searches involving android home button are generally unhelpful) and all I've really been able to find is that the home button seems to not be programmable anymore, it either sends you to the app home activity, or the activities parent activity which is what I'm trying to achieve. I'm assuming there's some way of doing this so any help would be much appreciated. I'm also just now learning android, maybe we can struggle through this together... Have you read this page? | ||
|
OsaX Nymloth
Poland3244 Posts
| ||
|
icystorage
Jollibee19350 Posts
now if I open it in a tablet like ipad, when it in landscape, it must show the 4 swimlanes. if it changes to portrait, it must change into an accordion (http://jqueryui.com/accordion/) how do I do this? media queries? do I make two types of html? | ||
|
OsaX Nymloth
Poland3244 Posts
Here's some examples: http://css-tricks.com/css-media-queries/ | ||
|
Shield
Bulgaria4824 Posts
Example:
So which is better to use - Example.getTest() or Example2.TEST? In other words, when you want to access a constant variable, do you do it from a getter method or direct variable access? I understand it's up to 'private' or 'public' but what's the decision making anyway? Is it just encapsulation (hiding implementation)? What if the method was static, then no instance is required, so would you still use a getter method over direct access to the variable? | ||
|
Tobberoth
Sweden6375 Posts
On January 30 2014 00:51 darkness wrote: I have a question about constants (in Java if it matters). Example:
So which is better to use - Example.getTest() or Example2.TEST? In other words, when you want to access a constant variable, do you do it from a getter method or direct variable access? I understand it's up to 'private' or 'public' but what's the decision making anyway? Is it just encapsulation (hiding implementation)? What if the method was static, then no instance is required, so would you still use a getter method over direct access to the variable? It depends. Since it's a constant, there's little reason to hide it, but it could be that you want to change how it's handled later, which a getter allows without editing the interface. This is why properties own, gives you the best of both worlds. | ||
|
Shield
Bulgaria4824 Posts
| ||
|
Tobberoth
Sweden6375 Posts
On January 30 2014 02:50 darkness wrote: Do you mean properties from Objective-C? I was specifically talking about C#, but there's similar concepts in tons of languages. | ||
|
misirlou
Portugal3241 Posts
On January 30 2014 02:31 Tobberoth wrote: Show nested quote + On January 30 2014 00:51 darkness wrote: I have a question about constants (in Java if it matters). Example:
So which is better to use - Example.getTest() or Example2.TEST? In other words, when you want to access a constant variable, do you do it from a getter method or direct variable access? I understand it's up to 'private' or 'public' but what's the decision making anyway? Is it just encapsulation (hiding implementation)? What if the method was static, then no instance is required, so would you still use a getter method over direct access to the variable? It depends. Since it's a constant, there's little reason to hide it, but it could be that you want to change how it's handled later, which a getter allows without editing the interface. This is why properties own, gives you the best of both worlds. Adding to this: To access 1st example you have to create an instance of Example to access a static constant which doesnt make much sense Example ex1=new Example(); The getter is a good idea indeed to change how the value is handled but it makes a lot more sense if it was a static getter since it's for a static field. | ||
| ||
StarCraft 2 StarCraft: Brood War Calm Dota 2Shuttle Horang2 Jaedong actioN Mini EffOrt ZerO Hyun Light [ Show more ] Counter-Strike Other Games Organizations
StarCraft 2 • StrangeGG StarCraft: Brood War• intothetv • AfreecaTV YouTube • Kozan • IndyKCrew • LaughNgamezSOOP • Migwel • sooper7s Dota 2 League of Legends Other Games |
|
StarCraft2.fi
Replay Cast
The PondCast
OSC
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
Korean StarCraft League
CranKy Ducklings
WardiTV 2025
SC Evo League
BSL 21
Sziky vs OyAji
Gypsy vs eOnzErG
[ Show More ] OSC
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
WardiTV 2025
OSC
BSL 21
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
Wardi Open
StarCraft2.fi
Monday Night Weeklies
Replay Cast
WardiTV 2025
StarCraft2.fi
PiGosaur Monday
|
|
|