[-] type TEAMS is record
[ ] int iYear
[ ] string sCity
[ ] string sName
[ ] string sSport
[ ]
[-] testcase Teams_Record() appstate none //declare a TEAMS variable called "myTeam"
[ ] TEAMS myTeam
[ ] //initialize myTeam
[ ] myTeam.iYear=1967
[ ] myTeam.sCity="Boston City"
[ ] myTeam.sName="Red Sox Team"
[ ] myTeam.sSport="Baseball Player"
[ ] //declare and initalize another variable called "myDramTeam"
[ ] TEAMS myDreamTeam={1999, "Boston", "Red Sox", "Baseball"} //print record info
[ ] print()
[ ] print("The whole record for myTeam:", myTeam)
[ ] print("The whole record:", myDreamTeam)
[ ] print("A piece of a record:", myDreamTeam.sCity+' '+myDreamTeam.sName)
输出:
[-] Testcase Teams_Record - Passed
[ ]
[ ] The whole record for myTeam: {1967, Boston City, Red Sox Team, Baseball Player}
[ ] The whole record: {1999, Boston, Red Sox, Baseball}
[ ] A piece of a record: Boston Red Sox
还有:
[ ] //declare a TEAMS variable entitled"ItClassics"
[-] List of TEAMS ItClassics={...}
[ ] {1975, "Cincinnati", "Reds", "Baseball"}
[ ] {1962, "New York", "Mets", "Baseball"}
[ ] {1988, "Edmonton", "Oilers", "Hockey"}
[ ] {1969, "Boston", "Cltics", "Baseball"}
[ ] {1965, "Green Bay", "Packers", "Football"}
[ ]
[-] testcase list_of_record()
[ ] Print()
[ ] ResPrintList("Classic Teams:", ItClassics)
[ ] Print()
[ ] Print("The alltime classic is:", ItClassics[2])
输出:
[-] Testcase list_of_record - Passed
[ ]
[-] Classic Teams:
[ ] {1975, Cincinnati, Reds, Baseball}
[ ] {1962, New York, Mets, Baseball}
[ ] {1988, Edmonton, Oilers, Hockey}
[ ] {1969, Boston, Cltics, Baseball}
[ ] {1965, Green Bay, Packers, Football}
[ ]
[ ] The alltime classic is: {1962, New York, Mets, Baseball}
如果去掉print(),则输出中没有空行。