val
중 임의의 것이 결과 목록에 오도록해야합니다. 여기 코드는 다음과 같습니다스칼라 : 발 순서의 임의 목록
def motivation(name:String, score:Int){
val quote1 = "You're not lost. You're locationally challenged." //score=10
val quote2 = "Time is the most valuable thing a man can spend." //score=20
val quote3 = "At times one remains faithful to a cause." //score=10
val quote4 = "Only because its opponents do not cease to be insipid." //score=10
val quote5 = "Life can be complicated." //score=20
case Some(score) => val quoteRes = shufle(????)
}
- 계산에 그것을 할 수 있도록 내가 각 따옴표의 점수를 표시하려면 어떻게합니까.
score
을 기준으로 임의로 따옴표를 선택하고shuffle
도 주문합니까? 예를 들어
존 (이름) (40) (점수)가있는 경우 결과 수있을 quotes2 + quotes3 + quotes4 또는 quotes4 + quotes5 또는 quotes1 + quotes2 + quotes5 내가 시작할 가능성이있을 거라고 생각
나는 쌍 (스코어, 따옴표)을 갖는 것이 더 좋을 것이라고 생각한다. 이 질문의 나머지 부분은 알고리즘입니다. – NaHeon