ruby - unexpected $nd expecting keyword end -


class csun def initialize() # create hashes  @lastnamehash = hash.new( ) @firstname = hash.new( ) @major = hash.new( ) @catalogyear = hash.new( ) puts "database created" end   # add record def addrecord () #prompt lastname, frstname, major, catalog year print "enter student's last name: " lastname = gets.chomp  print "enter student's first name: " firstname = gets.chomp  print "enter student's id: " id = gets.chomp  print "enter student's major: " major = gets.chomp  print "enter catalog year: " catalogyear = gets.chomp   if (@lastnamehash [id])     puts "student exists!"     return end   #store in hash @lastnamehash[id] = lastname @firstnamehash[id] = firstname @majorhash[id] = major @catalogyearhash[id] = catalogyear end   #update record def updaterecord() #prompt record id print "enter student's id: "     id=gets.chomp     if !(@lastnameash [id])     puts "record not exist"     return else     puts "update student's last name"     puts "current value: #{@lastnamehash [id]}"     print "new value: "     lastname = gets.chomp     @lastnamehash[id] = lastname       puts "update student's first name"     puts "current value: #{@firstnamehash [id]}"     print "new value: "     firstname = gets.chomp     @firstnamehash[id] = firstname      puts "update student's major"     puts "current value: #{@majorhash [id]}"     print "new value: "     major = gets.chomp     @majorhash[id] = major      puts "update student's catalog year"     puts "current value: #{@catalogyearhash [id]}"     print "new value: "     catalogyear = gets.chomp     @catalogyearhash[id] = catalogyear   end end  #delete record def deleterecord()  if !(@lastnameash [id])     puts "record not exist"     return     else     @lastnamehash.delete(id)     @firstnamehash.delete(id)     @majorhash.delete(id)     @catalogyear.delete(id)     puts"record deleted" end     #printrecord( )     def printrecord( )     @lastnamehash.each |key,value|     puts "student id: #{key}"     puts "last name: #{value}"     puts "first name: #{@firstnamehash[key]}"     puts "major: #{@majorhash[key]}"     puts "catalog year: #{@catalogyearhash[key]}" end   #save record def saverecord() print "save record (y/n): " save1 = gets.chomp if save1!= "y"     return else savefile = file.new("records.dat","w") contents = " "     @lastnamehash.each |key,value|     contents = contents + key + values + @firstnamehash[key] + majorhash[key] + catalogyearhash end  savefiles.syswrite (contents) savefiles.close() puts"contents saved" end  #main loop choice = 0 while (choice !=6) #propmt choice choice = gets.chomp case(choice)     when"1";         db = csun.new     when"2"         db.addrecord     when"3"         db.updaterecord     when"4"         db.deleterecord     when"5"         db.printrecord     when"6"         db.saverecord end end end 

i keep getting error "unexpected $nd expecting keyword end" know why getting error cant figure out end causing it

i need fresh eyes point me in right direction!

you missing end before def printrecord( ), end before saverecord() , final end on last line. please indent code!


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -