Exemplo n.º 1
0
	def writeFile(self):
		"""Write the end result to the file"""
		fileN = open ("game.data","w")
		write_recursion.write(fileN, self.root)
		fileN.close()
		# this doesn't work for some reason
		with open("game.data", "r+w") as f:
			for line in f:
				if line.strip():
					f.write(line)
Exemplo n.º 2
0
 def writeFile(self):
     """Write the end result to the file"""
     fileN = open("game.data", "w")
     write_recursion.write(fileN, self.root)
     fileN.close()
     # this doesn't work for some reason
     with open("game.data", "r+w") as f:
         for line in f:
             if line.strip():
                 f.write(line)
Exemplo n.º 3
0
from Tree import TreeNode
import write_recursion
sampleTree = TreeNode()

sampleTree.setValue(7)

sampleTree.addLeft(6)
sampleTree.addRight(10)
y = sampleTree.getLeft()
x = sampleTree.getRight()
x.addLeft(9)
x.addRight(57)

y.addLeft(8)
y.addRight(47)


def print_tree(tree):
    if tree == None:
        return
    print tree.item
    print_tree(tree.left)
    print_tree(tree.right)


print_tree(sampleTree)

gameData = open("testData.txt", "w")

write_recursion.write(gameData, sampleTree)
Exemplo n.º 4
0
import write_recursion 
sampleTree = TreeNode()

sampleTree.setValue(7)



sampleTree.addLeft(6)
sampleTree.addRight(10)
y = sampleTree.getLeft()
x = sampleTree.getRight()
x.addLeft(9)
x.addRight(57)

y.addLeft(8)
y.addRight(47)


def print_tree(tree):
                if tree == None: 
                        return
                print tree.item
                print_tree(tree.left)
                print_tree(tree.right)

print_tree(sampleTree)

gameData = open("testData.txt", "w")

write_recursion.write(gameData, sampleTree)