-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprogram
More file actions
executable file
·92 lines (64 loc) · 1.96 KB
/
program
File metadata and controls
executable file
·92 lines (64 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env ruby
require_relative "dosya"
require_relative "kullanici"
print "BookBank'a hoşgeldiniz. Size yardımcı olabilmem için lütfen yapmak istediğiniz işlemi belirtiniz: GİRİŞ: 1 ÜYE OLMAK İSTİYORUM: 2\n"
print "Yapmak istediğim işlem: "
loop do
uye_mi_degil_mi = gets.chomp.to_i
case uye_mi_degil_mi
when 1
print 'Enter an ID : '
id = gets.chomp
unless File.exist? "kullanicilar/#{id}"
puts "Bu id daha önce yok"
redo
end
dosya = Dosya.new("kullanicilar/#{id}")
kullanici = Kullanici.girdi(dosya.satirlar[0])
puts "Kullanıcı puanı: #{kullanici.point}"
puts "Kitaplarınız: "
kullanici.kitaplar.each { |kitap| puts kitap }
puts "Kitap Almak İstiyor musunuz? evet-1 hayır-2"
kitapAlma = gets.chomp.to_i
case kitapAlma
when 1
puts "Kitap Seçin ve kitabın kodunu girin :"
f = File.open("kitap_listesi","r")
puts f.read()
f.close()
kod = gets.chomp.to_i - 1
# kitap_girdi = gets.chomp
dosya.satirlar.delete_at(kod) #buradaki kod dediğim şey, kitaplara verilecex index kodudur.
#dosya.cikar(kitap_girdi)
break
when 2
break
end
break
when 2
puts "Memnuniyetle! Üyelik sayfasına yönlendiriliyorsunuz"
puts "Kullanıcı ID girer misin? "
id = gets.chomp
if File.exist? "kullanicilar/#{id}"
puts "Bu id daha önce var"
redo
end
puts "Kitap söyler misin? "
kitap = gets.chomp
puts "Yazar söyler misin? "
yazar = gets.chomp
puts "Kitabınız kaç sayfa? "
sayfa = gets.chomp
puan = sayfa.to_f * 0.25
puan = 200 if puan > 200
kullanici = Kullanici.new([puan, [kitap]])
dosya = Dosya.new("kullanicilar/#{id}")
dosya.olustur(kullanici.cikti)
kitaplar_dosya = Dosya.new("kitap_listesi")
kitaplar_dosya.ekle("#{kitap},#{yazar},#{puan}")
puts "Teşekkür Ederiz"
break
when 3
break
end
end