我有以下课程:
class Team{
String name
boolean club
}
class Result{
int goals1
int goals2
}
class SingleMatch {
Team team1
Team team2
Date startDate
Result firstHalfResult
Result secondHalfResult
Result extraTimeResult
Result penaltyResult
}
我正在尝试在BootStrap.groovy中实例化这些类。但我不知道如何实例化SingleMatch类。
Team _team1 = new Team(name: "Fiorentina",club: true)
Team _team2 = new Team(name:"Juventus",club: true)
Result a = new Result(goals1: 1, goals2: 0)
Result b = new Result(goals1: 0, goals2: 2)
Result c = new Result(goals1: 1, goals2: 0)
Result d = new Result(goals1: 5, goals2: 4)
SingleMatch match1 = new SingleMatch(team1: _team1, team2: _team2, startDate: new Date(), firstHalfResult: a, secondHalfResult: b, extraTimeResult: c, penaltyResult: d)
这是正确的方法吗?
答案 0 :(得分:0)
首先尝试保存..
Arr