Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class UserInterface
- {
- static UserInterface intFace = new UserInterface();
- static SongDatabase dataMain = new SongDatabase();
- public static String artist;
- public static String name;
- public static double duration;
- public static int fileSize;
- private void run() {
- }
- public static void main(String[] args){
- Scanner console = new Scanner(System.in);
- do
- {
- System.out.println("\t MENU");
- System.out.println("0 EXIT");
- System.out.println("1 IMPORT TRACK");
- System.out.println("2 SHOW ALL");
- int switchOption = console.nextInt();
- switch(switchOption) {
- case 0 :
- System.out.println("Exiting");
- break;
- case 1 :
- System.out.println("Adding new track");
- userImport();
- break;
- case 2 :
- System.out.println("Scanning file system");
- showFileSystem();
- break;
- default:
- System.out.println("Invalid option");
- break;
- }
- }while(true);
- }
- public static void showFileSystem()
- {
- int check = 1;
- Scanner console = new Scanner(System.in);
- System.out.println("Welcome to the system file scanner!");
- System.out.println("Scan now? (0)=yes, (1)=no."); check = console.nextInt();
- if (check==0) {
- System.out.println("System contents:"+dataMain.dataSlotCheck());
- }else{ System.out.println("Exiting file scanner..");
- }
- }
- public static void userImport()
- {
- String userin1;
- String userin2;
- double userin3;
- int userin4;
- Scanner console = new Scanner(System.in);
- Song songMain = new Song();
- System.out.println("Welcome to the music importer!");
- System.out.println("Music can be imported in the format Artist:TrackName:Duration(mm.ss):FIleSize(kb)");
- System.out.println("Enter the artist:.."); userin1 = console.nextLine();
- System.out.println("Enter the track title:.."); userin2 = console.nextLine();
- System.out.println("Enter the duration:.."); userin3 = console.nextDouble();
- System.out.println("Enter the file size:.."); userin4 = console.nextInt();
- intFace.importAssign(userin1, userin2, userin3, userin4);
- dataMain.addSong();
- songMain.returnData();
- }
- public void importAssign(String userin1, String userin2, double userin3, int userin4) {
- intFace.artist = userin1;
- intFace.name = userin2;
- intFace.duration = userin3;
- intFace.fileSize = userin4;
- }
- }
- __________________________________________________________________________________________
- public class SongDatabase
- {
- UserInterface intFace = new UserInterface();
- Song Set = new Song();
- private Song a = new Song();
- private Song b = new Song();
- private Song c = new Song();
- private Song d = new Song();
- public void addSong()
- {
- if (a.songfileSize==0) {
- setData(a.songartist, a.songname, a.songduration, a.songfileSize);
- } else if (b.songfileSize==0) {
- setData(b.songartist, b.songname, b.songduration, b.songfileSize);
- } else if (c.songfileSize==0) {
- setData(c.songartist, c.songname, c.songduration, c.songfileSize);
- } else if (d.songfileSize==0) {
- setData(c.songartist, c.songname, c.songduration, c.songfileSize);
- } else {
- System.out.println("Error: there is no free space in the database");
- }
- }
- public void setData( String artist, String name, double duration, int fileSize)
- {
- Set.setArtist(intFace.artist);
- Set.setName(intFace.name);
- Set.setDuration(intFace.duration);
- Set.setFileSize(intFace.fileSize);
- }
- public String dataSlotCheck()
- {
- String finalScan;
- if (a.songfileSize==0 && b.songfileSize==0 && c.songfileSize==0 && d.songfileSize==0) {
- finalScan=("There is no music stored in the database.");
- }
- else if (d.songfileSize==0 && c.songfileSize==0 && b.songfileSize==0) {
- finalScan=("SlotA:"+a.songartist+":"+a.songname+":"+a.songduration+":"+a.songfileSize);
- } else if (d.songfileSize==0 && c.songfileSize==0) {
- finalScan= ("SlotA:"+a.songartist+":"+a.songname+":"+a.songduration+":"+a.songfileSize+
- "SlotB:"+b.songartist+":"+b.songname+":"+b.songduration+":"+b.songfileSize);
- } else if (d.songfileSize==0) {
- finalScan= ("SlotA:"+a.songartist+":"+a.songname+":"+a.songduration+":"+a.songfileSize+
- "SlotB:"+b.songartist+":"+b.songname+":"+b.songduration+":"+b.songfileSize+
- "SlotC:"+c.songartist+":"+c.songname+":"+c.songduration+":"+c.songfileSize);
- } else {
- finalScan= ("SlotA:"+a.songartist+":"+a.songname+":"+a.songduration+":"+a.songfileSize+
- "SlotB:"+b.songartist+":"+b.songname+":"+b.songduration+":"+b.songfileSize+
- "SlotC:"+c.songartist+":"+c.songname+":"+c.songduration+":"+c.songfileSize+
- "SlotD:"+d.songartist+":"+d.songname+":"+d.songduration+":"+d.songfileSize);
- }
- return (finalScan);
- }
- }
- ________________________________________________________________________________________________
- public class Song
- {
- public Song(){
- /*Artist;
- * TrackName;
- * Duration(mm:ss);
- * fileSize(kB);*/
- }
- UserInterface intFace = new UserInterface();
- String songartist = intFace.artist;
- String songname = intFace.name;
- double songduration = intFace.duration;
- int songfileSize = intFace.fileSize;
- public void Song(String artist, String name, double duration, int fileSize){
- this.artist=artist;
- this.name=name;
- this.duration=duration;
- this.fileSize=fileSize;
- }
- public void setArtist(String newArtist)
- {
- artist = newArtist;
- }
- public String getArtist()
- {
- return artist;
- }
- public void setName(String newName)
- {
- name = newName;
- }
- public String getName()
- {
- return name;
- }
- public void setDuration(double newDuration)
- {
- duration = newDuration;
- }
- public double getDuration()
- {
- return duration;
- }
- public void setFileSize(int newFileSize)
- {
- fileSize = newFileSize;
- }
- public int getFileSize()
- {
- return fileSize;
- }
- public String returnData()
- {
- return ("You have imported: "+intFace.name+" By: "+intFace.artist+" || "
- +intFace.duration+"(mm.ss), "+intFace.fileSize+"(kB)");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment