mirror of
https://github.com/Rushilwiz/APCS.git
synced 2025-04-06 05:20:21 -04:00
80 lines
1.7 KiB
Java
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;
|
|
}
|
|
}
|