当前位置: 首页>>代码示例>>Python>>正文


Python Node.get_next方法代码示例

本文整理汇总了Python中Node.Node.get_next方法的典型用法代码示例。如果您正苦于以下问题:Python Node.get_next方法的具体用法?Python Node.get_next怎么用?Python Node.get_next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


在下文中一共展示了Node.get_next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_question_three

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_next [as 别名]
def test_question_three():
	print('\nTesting Question Three\n--------------------')
	
	#Test1
	print("Test 1\n")
	first_node = Node("ann")
	second_node = Node("bob")
	third_node = Node("cat")
	first_node.set_next(second_node)
	second_node.set_next(third_node)
	expected_chain = "ann cat bob None"
	original_chain = ""
	original_chain += str(first_node) + " "
	original_chain += str(first_node.get_next()) + " "
	original_chain += str(first_node.get_next().get_next()) + " "
	original_chain += str(first_node.get_next().get_next().get_next())	
	Asst2.back_to_front_chain(first_node)
	new_chain = ""
	new_chain += str(first_node) + " "
	new_chain += str(first_node.get_next()) + " "
	new_chain += str(first_node.get_next().get_next()) + " "
	new_chain += str(first_node.get_next().get_next().get_next())
	print("Original chain = ", original_chain)
	print("Expected chain = ", expected_chain)
	print("New chain      = ", new_chain)
	display_message(expected_chain == new_chain)
	print()
开发者ID:comradesmith,项目名称:UoA,代码行数:29,代码来源:PaulsTestProgramAsst2.py

示例2: test_question_three

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_next [as 别名]
def test_question_three():
    print('\n====================\n Testing Question 3\n====================')

    first_node = Node('ann')
    second_node = Node('bob')
    third_node = Node('cat')
    first_node.set_next(second_node)
    second_node.set_next(third_node)
    Asst2.back_to_front_chain(first_node)
    
    print('Test 1\n', '  Expected = ann cat bob None', '\n   Got      =', end = ' ')

    print(first_node.get_data(), end = ' ')
    print(first_node.get_next().get_data(), end = ' ')
    print(first_node.get_next().get_next().get_data(), end = ' ')
    print(first_node.get_next().get_next().get_next())

    first_node = Node(1)
    second_node = Node(2)
    third_node = Node(3)
    fourth_node = Node(4)
    fifth_node = Node(5)
    first_node.set_next(second_node)
    second_node.set_next(third_node)
    third_node.set_next(fourth_node)
    fourth_node.set_next(fifth_node)

    Asst2.back_to_front_chain(first_node)
    
    print('Test 2\n', '  Expected = 1 5 2 3 4 None', '\n   Got      =', end = ' ')

    print(first_node.get_data(), end = ' ')
    print(first_node.get_next().get_data(), end = ' ')
    print(first_node.get_next().get_next().get_data(), end = ' ')    
    print(first_node.get_next().get_next().get_next().get_data(), end = ' ')
    print(first_node.get_next().get_next().get_next().get_next().get_data(), end = ' ')
    print(first_node.get_next().get_next().get_next().get_next().get_next())

    first_node = Node(1)
    second_node = Node(2)

    first_node.set_next(second_node)

    Asst2.back_to_front_chain(first_node)
    
    print('Test 3\n', '  Expected = 1 2 None', '\n   Got      =', end = ' ')

    print(first_node.get_data(), end = ' ')
    print(first_node.get_next().get_data(), end = ' ')
    print(first_node.get_next().get_next())
开发者ID:comradesmith,项目名称:UoA,代码行数:52,代码来源:ClarissaTest.py


注:本文中的Node.Node.get_next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。