From 99b7968aea5750c11c1e6be2c52a44f81dc4aea0 Mon Sep 17 00:00:00 2001 From: Marcio Vicente Date: Tue, 13 May 2014 12:00:09 -0300 Subject: [PATCH] Using the new 'type' of struct. Class instead variable --- main.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index 153dee1..3e9edf4 100644 --- a/main.py +++ b/main.py @@ -12,14 +12,21 @@ # TODO - Change another name to Appliocation class # because this must be a node of list, and not an application -class Application(object): - """ Application Class """ +class Node(object): + """docstring for Node""" def __init__(self): - self.method = None self.value = None self.sequence = None self.age = None + super(Node, self).__init__() + + +class Application(object): + """ Application Class """ + + def __init__(self): + self.method = None self.file = None self.filename = 'binary' self.SIZE_OF_FILE = 11 @@ -35,12 +42,6 @@ def main(self): elif operation != 'e': return - # UNUSED - def get_entries(self): - self.value = raw_input() - self.sequence = raw_input() - self.age = raw_input() - def mod(self, n): return n % self.SIZE_OF_FILE @@ -54,17 +55,21 @@ def point_to_value(self, value): self.file.seek(index) def insert_record(self): - self.value = raw_input() - self.sequence = raw_input() - self.age = raw_input() + value = raw_input() + sequence = raw_input() + age = raw_input() + n = Node() + n.value = value + n.sequence = sequence + n.age = age if self.file: - self.point_to_value(self.value) + self.point_to_value(n.value) if self.file.read(): # ie, if has colision - print 'chave ja existente: %s' % self.value + print 'chave ja existente: %s' % n.value self.solve_colision() else: - self.file.write(str(self.value)) + self.file.write(str(n.value)) def query(self): value = raw_input() @@ -81,8 +86,6 @@ def close_file(self): if self.file: self.file.close() - - app = Application() app.main()