APCS/11 Huffman/01_02 Huffman Coding/deHuffman.java
Rushil Umaretiya 3fc3554899 initial commit
2020-12-04 22:00:49 -05:00

80 lines
1.7 KiB
Java

// Name: Date:
import java.util.*;
import java.io.*;
public class deHuffman
{
public static void main(String[] args) throws IOException
{
Scanner keyboard = new Scanner(System.in);
System.out.print("\nWhat binary message (middle part)? ");
String middlePart = keyboard.next();
Scanner sc = new Scanner(new File("message."+middlePart+".txt"));
String binaryCode = sc.next();
Scanner huffLines = new Scanner(new File("scheme."+middlePart+".txt"));
TreeNode root = huffmanTree(huffLines);
String message = dehuff(binaryCode, root);
System.out.println(message);
sc.close();
huffLines.close();
}
public static TreeNode huffmanTree(Scanner huffLines)
{
}
public static String dehuff(String text, TreeNode root)
{
}
}
/* TreeNode class for the AP Exams */
class TreeNode
{
private Object value;
private TreeNode left, right;
public TreeNode(Object initValue)
{
value = initValue;
left = null;
right = null;
}
public TreeNode(Object initValue, TreeNode initLeft, TreeNode initRight)
{
value = initValue;
left = initLeft;
right = initRight;
}
public Object getValue()
{
return value;
}
public TreeNode getLeft()
{
return left;
}
public TreeNode getRight()
{
return right;
}
public void setValue(Object theNewValue)
{
value = theNewValue;
}
public void setLeft(TreeNode theNewLeft)
{
left = theNewLeft;
}
public void setRight(TreeNode theNewRight)
{
right = theNewRight;
}
}