Skip to main content
edited body
Source Link
Eric Duminil
  • 4k
  • 1
  • 19
  • 27

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book, LinkedList, and Bookstore(LinkedList).

  • Node should have define a data attribute for Node.

  • define __str__ for Node, which just delegates to data.__str__.

  • define __str__ for Book, which joins id, bookName and authorName.

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book, LinkedList, and Bookstore(LinkedList).

  • Node should have a data attribute.

  • define __str__ for Node, which just delegates to data.__str__.

  • define __str__ for Book, which joins id, bookName and authorName.

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book, LinkedList, and Bookstore(LinkedList).

  • define a data attribute for Node.

  • define __str__ for Node, which just delegates to data.__str__.

  • define __str__ for Book, which joins id, bookName and authorName.

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

deleted 6 characters in body
Source Link
Eric Duminil
  • 4k
  • 1
  • 19
  • 27

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book(Node), LinkedList, and Bookstore(LinkedList).

  • Node should have a data attribute.

  • define __str__ for Node, which just delegates to data.__str__.

  • define __str__ for Book, which joins id, bookName and authorName.

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book(Node), LinkedList, and Bookstore(LinkedList).

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book, LinkedList, and Bookstore(LinkedList).

  • Node should have a data attribute.

  • define __str__ for Node, which just delegates to data.__str__.

  • define __str__ for Book, which joins id, bookName and authorName.

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

added 250 characters in body
Source Link
Eric Duminil
  • 4k
  • 1
  • 19
  • 27

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book(Node), LinkedList, and Bookstore(LinkedList).

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

It looks good and readable IMHO. For brownie points, you could:

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

It looks good and readable IMHO. For brownie points, you could:

  • modify the structure a bit. Not every LinkedList will contain books. Similarly, not every Node in a LinkedList will have an AuthorName. You could define 4 separate classes : Node, Book(Node), LinkedList, and Bookstore(LinkedList).

  • run autopep8 to fix a few minor formatting problems (e.g. self.size+=1 -> self.size += 1).

  • add a delimiter to DisplayBook() between id, bookName and authorName. If the names have spaces, you wouldn't know what the name of the book is.

  • write tests, for example to check that the LinkedList has a correct length or that DisplayBook() displays the names in correct order. You'd be allowed to use Python lists and sorted() inside the tests. DisplayBook() only prints information and doesn't return anything, so you might have to redirect stdout.

  • move the examples at the end to main() and check if you're importing the file as a library or running the script. See here.

  • suggest better method names to your teacher. Python classes are CamelCase but methods are snake_case. Also DisplayBook seems to suggest that it displays one single book. It could be called display_books.

  • define a generator for LinkedList, which would iterate over every Node. You might not be allowed to use it in your answer, it would make it much easier to use your library, though.

Source Link
Eric Duminil
  • 4k
  • 1
  • 19
  • 27
Loading