ruby に問題があります。指定した配列にファイルが読み込まれません。
class Dancer
def Initialize (couplenumber, score1, score2, score3, score4, score5, score6, score7)
@couplenumber = couplenumber
@score1 = score1
@score2 = score2
@score3 = score3
@score4 = score4
@score5 = score5
@score6 = score6
@score7 = score7
end
def show()
return "Couple Number: #{@couplenumber}. Scores: #{@score1}, #{@score2}, #{@score3}, #{@score4}, #{@score5}, #{@score6}, #{@score7}."
end
end
results = File.open("danceresult.txt", "r+")
dancescores = []
# Splitting dance scores with "," and putting into arrays.
for dancers in results
a = dancers.split(",")
couplenumber = a[0]
score1 = a[1]
score2 = a[2]
score3 = a[3]
score4 = a[4]
score5 = a[5]
score6 = a[6]
score7 = a[7]
dancescores << Dancer.new
end
dancescores.each do |dance|
puts dance.show
end
私の問題は、Ruby のみがこれを渡すことです:
Couple Number: . Scores: , , , , , , .
Couple Number: . Scores: , , , , , , .
Couple Number: . Scores: , , , , , , .
Couple Number: . Scores: , , , , , , .
Couple Number: . Scores: , , , , , , .
Couple Number: . Scores: , , , , , , .
私はコーディングが苦手で、まだ勉強中です :-) よろしくお願いします。