summaryrefslogtreecommitdiff
path: root/sem_5/HLIN505_Java/HLIN505/src/TP4/SimplePlayList.java
blob: a65fc25ebda429415d157da68fa006f9a1506219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package TP4;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class SimplePlayList extends AbstractAudioElement implements Iplaylist{
	private ArrayList<Song> liste;
	private int Length;
	private int Size;
	private int nbElements;
	public SimplePlayList (String titre, String Path) throws IOException {
		super(Path);
		setName(titre);
		if (!getFichier().exists()) {
			getFichier().createNewFile();
		}
		
		
	}
	private void browseFile() throws IOException, NumberFormatException, IncorrectFileNameException {
		BufferedReader read = new BufferedReader(new FileReader(getPath()));
		String tmp = read.readLine();
		while (!tmp.isEmpty()) {
			liste.add(new Song(Integer.parseInt(tmp.split("\\")[0]),tmp.split("\\")[1],tmp.split("\\")[2],tmp.split("\\")[3]));
			tmp = read.readLine();
		}
		read.close();
	}
	public int getLength() {
		return this.Length;
	}
	public void setLength() {
		Length=0;
		for ( Song s : liste) {
			Length+=s.getLength();
		}
	}
	public int getSize() {
		return this.Size;
	}
	public void setSize() throws SecurityException{
		Size = 0;
		for(Song s : liste) {
			Size+=s.getSize();
		}
	}
	public int getnbElements() {
		return nbElements;
	}
	public void setNbElements() {
		nbElements=liste.size();
	}
	@Override
	public void setLength(int length) {
		// TODO Auto-generated method stub
		
	}
	}