-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileAllocation.java
More file actions
57 lines (55 loc) · 1.75 KB
/
FileAllocation.java
File metadata and controls
57 lines (55 loc) · 1.75 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
package fileallocation;
import java.util.ArrayList;
import java.util.Scanner;
public class FileAllocation
{
public static void main(String[] args)
{
ArrayList<Fylat> files = new ArrayList();
int filesize, blocknum,filenum;
String filename;
Scanner input=new Scanner(System.in);
System.out.println("*********************************************\n");
System.out.println("Welcome to 'THE ALLOCATION PROGRAM' \n");
System.out.println("*********************************************\n\n\n");
System.out.println("Enter memory block size:");
blocknum=input.nextInt();
System.out.println("Enter files number:");
filenum=input.nextInt();
System.out.println ("\nPlease enter the name and size of each file:\n");
for (int i = 0; i < filenum; i++)
{
filename=input.next();
filesize=input.nextInt();
files.add(new Fylat(filename,filesize));
}
Allocate x=new Allocate(blocknum,files);
System.out.println("Choose your needed method:");
System.out.println("Press 1 for Contiguous");
System.out.println("Press 2 for Linked");
System.out.println("Press 3 for Indexed");
int w=input.nextInt();
System.out.println("\n");
switch(w)
{
case 1:
{
x.contiguous();
x.display();
break;
}
case 2:
{
x.linked();
x.display();
break;
}
case 3:
{
x.indexed();
x.display();
break;
}
}
}
}