//This class is the main one which is used to act as a directory class Node{ protected String Name; protected int size; protected Node parent; protected Node child; protected Node next; protected String type; protected int access; protected int year,month,date,hour,minutes; //Constructor public Node(){ Name=""; parent=null; child=null; next=null; type="0"; access=0; year=2002; month=10; date=2; hour=21; minutes=10; } //Constructor with various parameters being passed be written here //Is directory empty ? public boolean isEmpty(){ return(next==null); } //Funcion to add subdirectory or file public void addChild(Node n) { if(type.equalsIgnoreCase("dir")) { if(size==0) { child=n; size++; } else { Node temp; boolean flag=true; temp=child; String old=temp.getName(); String add=n.getName(); while(temp!=null&&flag) { old=temp.getName(); if(!(old.equals(add)&&n.getType().equals(temp.getType()))) { if(temp.getNext()==null) { temp.setNext(n); size++; flag=false; } else temp=temp.getNext(); } else flag=false; } } } else System.out.println("\nThis is not directory"); } //Function to setChild public void setChild(Node n) { child=n; } //Function to get the type of file or directory public String getType() { return type; } //Function to set Name of file/directory public void setName(String s){ Name=s; } //Function to get Child public Node getChild() { return child; } //Function to get Parent of the directory public Node getParent() { return parent; } //Function to get size public int getSize() { return size; } //Function to get Name of directory public String getName(){ return Name; } //Function to set size public void setSize(int n) { size=n; } //Function to return path of the directroy public String getPath() { String path=Name; Node temp=parent; while(temp!=null) { path=temp.getName()+'/'+path; temp=temp.getParent(); } return path; } } //Many other function follow here involving getting date of last access and //others. //Write the class here that simulates the UNIX OS involing a loop calling //various methods discussed above and some others.