1 년 동안 프로그래밍하지 않았으므로 조금 녹슬 었습니다. 정말 링크 목록을 통합하고 싶지만 코드 작동 방식을 기억하는 데 어려움이 있습니다. 파이썬으로 구현해야하는 것은 도움이되지 않습니다.Python/linked list/dynamic/overloading
지금까지 노드 클래스 만 설정되었습니다. 분명히, 나는 성가신입니다 오버로드 된 생성자를 사용하지 않습니다 ...
기본적으로 나는 사용자에게 물통의 X 번호를 입력하라는 프로그램을 작성하고 싶습니다. 각 양동이에는 X 개의 다른 색상 볼이 있습니다. 사용자는 각 색상별로 볼 수를 지정합니다.
도움을 언제나 환영합니다!
class Node:
def __init__(self, bucketNumber ,colorONE, colorTWO,
colorTHREE, colorFOUR, colorFIVE):
self.bucket = bucketNumber # index
self.color1 = colorONE # quantity
self.color2 = colorTWO # quantity
self.color3 = colorTHREE # quantity
self.color4 = colorFOUR # quantity
self.color5 = colorFIVE # quantity
def printN(bucketNum):
for i in range(0,bucketNum):
print(nodes[i].bucket, nodes[i].color1, nodes[i].color2, nodes[i].color3, nodes[i].color4, nodes[i].color5)
colors = []
nodes = []
count = []
bucketNum = int(raw_input("The are 2-5 buckets with 2-5 ball colors. Enter number of Buckets:"))
colorNum = int(raw_input("Enter number of Colors:"))
for i in range(0,colorNum):
colors.append(raw_input("Enter color: " + str(i+1)))
for i in range(0,bucketNum):
for j in range(0,colorNum):
count.append((raw_input("How many "+ colors[j] +" balls in bucket " + str(i+1))))
nodes.append(Node(i+1, count[0], count[1], count[2], count[3], count[4]))
del count[ 0:len(count) ]
for i in range(0,colorNum):
print colors[i],
print " "
printN(bucketNum)
정확히 무엇이 문제입니까? –