中级农民
- 积分
- 106
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2019-4-8
- 最后登录
- 1970-1-1
|
本帖最后由 anna368 于 2019-8-26 08:35 编辑
认真回答:
val priorityQueue = PriorityQueue(compareByDescending<Lady> { it.appearance }
.thenByDescending { it.background }
.thenByDescending { it.personality }
.thenByDescending { it.lifeStyle }
.thenByDescending { it.salary }
.thenByDescending { it.education })
val a = Lady("A", salary = 100, background = 100, lifeStyle = 50)
val b = Lady("B", appearance = 100, personality = 100)
priorityQueue.offer(a)
priorityQueue.offer(b)
println("marry ${priorityQueue.poll()}")
println("was divorced by my wife and lost money")
println("marry ${priorityQueue.poll()}")
println("was divorced by my wife and got some money")
println("marry ${priorityQueue.poll()}")
println("孤独一生")
------
marry Lady(name=B, salary=0, education=0, appearance=100, background=0, personality=100, lifeStyle=0)
was divorced by my wife and lost money
marry Lady(name=A, salary=100, education=0, appearance=0, background=100, personality=0, lifeStyle=50)
was divorced by my wife and got some money
marry null
孤独一生
Process finished with exit code 0
不过我是女的 ( ′・・)ノ(._.`)
|
|