I'm creating simple game in Java which plays music in background.
Music class contains those static methods:
- playMusic();
- stopMusic();
- changeVol(int vol);
At the very begin I'm crating new object of 'Music' class and I'm calling static method 'playMusic':
new Music();
Music.playMusic();
The reason why those methods are static is that I want to start playing music when application starts but You can chose if music is played or not in settings. Static methods provide the easiest way of doing it since 'Settings' class does`t have 'main' method.
The Music class code:
public class Music {
/// ... variables
public Music(){
try{
/// ... Preparing clip to play
} catch (Exception e){
/// ... Catching exception
}
}
public static void playMusic(){
/// ... starting music
}
public static void stopMusic(){
/// stoping music
}
public static void changeVol(int vol){
/// changing volume
}}
It works perfectly fine but I wondering if it's correct with OOP and Java standards?
Full Music class code: http://pastebin.com/d9XYX1gG
Musicas your application starts up.