-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOblig5Del1.java
More file actions
58 lines (41 loc) · 1.53 KB
/
Oblig5Del1.java
File metadata and controls
58 lines (41 loc) · 1.53 KB
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
import java.io.File;
import java.util.HashMap;
public class Oblig5Del1 {
// Lag nytt register for testobjektet
SubsekvensRegister nytt = new SubsekvensRegister();
Oblig5Del1(String filnavn){
try {
File folder = new File(filnavn);
//Lager ny liste med alle filene i en mappe
File[] filListe = folder.listFiles();
for(File filer: filListe){
nytt.lagHashMapFraFil(filer);
}
}
catch (Exception e) {
System.out.println("Filen finnes ikke");
}
HashMap<String, Subsekvens> nyHash = new HashMap<>();
for(HashMap<String, Subsekvens> hashMap: nytt.lokaltRegister) {
HashMap<String, Subsekvens> resultatHash = nytt.SlaaSammenHashMap(hashMap, nyHash);
nyHash = resultatHash;
}
Subsekvens stoersteSekvens = null;
for(Subsekvens items : nyHash.values()){
if(stoersteSekvens != null){
if( stoersteSekvens.hentAntallForekomster() < items.hentAntallForekomster()){
stoersteSekvens = items;
}
}
else if( stoersteSekvens == null){
stoersteSekvens = items;
}
}
System.out.println(stoersteSekvens + " forekommer flest ganger");
}
}
class Test2{
public static void main(String[] args) {
new Oblig5Del1(args[0]);
}
}