setscreen ("graphics:800,400")
var name : flexible array 1 .. 6 of string
var model : flexible array 1 .. 6 of string
var company : flexible array 1 .. 6 of string
var phone : flexible array 1 .. 6 of string
var snowday : flexible array 1 .. 6 of int
var experience : flexible array 1 .. 6 of int
var choice : int
var font1 : int
var font2 : int
var total : real
var large : int
var small : int
var delete : int
var add : int
var num : int
var aver : real
var main : string (1)
var l : string
var s : string
%var pic : int := Pic.FileNew ("pollard7.jpg")
%var picID : int := Pic.FileNew ("pollard10.jpg")
%var picID2 : int := Pic.FileNew ("skiing.jpg")
%var picID3 : int := Pic.FileNew ("pollard3.jpg")
%var picID4 : int := Pic.FileNew ("FR1203_frz03.jpg")
num := upper (name)
total := 0
large := 0
small := 100000
font1 := Font.New ("Ravie:10")
font2 := Font.New ("Ravie:28")
var fileName : string := "database.txt"
var file : int
%------------------------------------------------------------------------------------------
proc savestuff
open : file, fileName, put
for i : 1 .. upper (name)
put : file, name (i), company (i), model (i), phone (i), snowday (i), experience (i)
end for
close (file)
end savestuff
proc getstuff
open : file, fileName, get
for i : 1 .. upper (name)
exit when eof (file)
get : file, name (i) : *
end for
close (file)
end getstuff
%------------------------------------------------------------------------------------------
%proc values
%name (1) := "Carl Holland"
%name (2) := "Jake Reid"
%name (3) := "Alen Kimple"
%name (4) := "Ryan Lowe"
%name (5) := "Kevin Edwards"
%name (6) := "Sam Burns"
%company (1) := "Rossignol/Armada"
%company (2) := "Head/LINE"
%company (3) := "Armada/LINE"
%company (4) := "Rossignol"
%company (5) := "Atomic"
%company (6) := "Atomic"
%model (1) := "Scratch FS/ARV"
%model (2) := "Mad Trix/Twelve Sixty"
%model (3) := "AR5/Twelve Sixty"
%model (4) := "Carve 5.0"
%model (5) := "S-Daddy Pimp"
%model (6) := "Beta Carve 9.1"
%phone (1) := "(905 - 668 - 8687)"
%phone (2) := "(905 - 683 - 1059)"
%phone (3) := "(905 - 683 - 5697)"
%phone (4) := "(905 - 721 - 5286)"
%phone (5) := "(905 - 896 - 6427)"
%phone (6) := "(905 - 668 - 1384)"
%snowday (1) := 67
%snowday (2) := 71
%snowday (3) := 73
%snowday (4) := 50
%snowday (5) := 2
%snowday (6) := 12
%experience (1) := 10
%experience (2) := 10
%experience (3) := 9
%experience (4) := 7
%experience (5) := 17
%experience (6) := 7
%end values
%------------------------------------------------------------------------------------------
proc displayall
getstuff
color (116)
cls
%Pic.Draw (picID2, 480, 25, picCopy)
locate (4, 7)
put "Name Fav Company Weapon of choice Years of experience"
for i : 1 .. upper (name)
locate (6 + i, 7)
put name (i)
locate (6 + i, 25)
put company (i)
locate (6 + i, 50)
put model (i)
locate (6 + i, 81)
put experience (i)
end for
put ""
put ""
put "Hit a key to return to the menu"
getch (main)
end displayall
%------------------------------------------------------------------------------------------
proc average
getstuff
color (42)
total := 0
for i : 1 .. upper (snowday)
total := total + snowday (i)
end for
aver := total / upper (snowday)
cls
put "The average number of days on the hill last year was ", aver : 4 : 2
put "Hit a key to return to the menu"
% Pic.Draw (picID3, 200, 50, picCopy)
getch (main)
end average
%------------------------------------------------------------------------------------------
proc mostexperience
getstuff
color (5)
for i : 1 .. upper (experience)
if experience (i) > large then
large := experience (i)
l := name (i)
end if
end for
cls
put ""
put "The the person with the most experience is ", l, " : ", large, " years."
put ""
put "Hit a key to return to the menu"
getch (main)
end mostexperience
%------------------------------------------------------------------------------------------
proc leastexperience
getstuff
for i : 1 .. upper (experience)
if experience (i) < small then
small := experience (i)
s := name (i)
end if
end for
cls
put ""
put "The the person with the least experience is ", s, " : ", small, " years."
put ""
put "Hit a key to return to the menu"
getch (main)
end leastexperience
%------------------------------------------------------------------------------------------
proc deletestuff
getstuff
color (64)
if upper (name) = 1 then
cls
put "Cannot delete item!"
else
loop
cls
for i : 1 .. upper (name)
put i, " ", name (i)
end for
put ""
put "What name would you like to delete? " ..
get delete
exit when delete <= upper (name) and delete > 0
end loop
for i : 1 .. upper (name)
if delete = i then
for i2 : i .. upper (name) - 1
name (i2) := name (i2 + 1)
company (i2) := company (i2 + 1)
model (i2) := model (i2 + 1)
phone (i2) := phone (i2 + 1)
snowday (i2) := snowday (i2 + 1)
experience (i2) := experience (i2 + 1)
end for
end if
end for
new name, upper (name) - 1
new company, upper (name)
new model, upper (name)
new phone, upper (name)
new snowday, upper (name)
new experience, upper (name)
locate (22, 36)
put "Name #", delete, " Deleted"
delay (2000)
end if
end deletestuff
%------------------------------------------------------------------------------------------
proc addstuff
getstuff
color (63)
cls
new name, upper (name) + 1
new company, upper (company) + 1
new model, upper (model) + 1
new phone, upper (phone) + 1
new snowday, upper (snowday) + 1
new experience, upper (experience) + 1
put "Enter the persons name."
get name (upper (name))
put "Enter their favorite company."
get company (upper (company))
put "Enter the model they ski."
get model (upper (model))
put "Enter phone number (ie 905 - 678 - 4567)."
get phone (upper (phone))
put "Enter how many days the person skied last year."
get snowday (upper (snowday))
put "Enter how many yearrs of experience."
get experience (upper (experience))
locate (22, 36)
put "Name added"
delay (2000)
end addstuff
%------------------------------------------------------------------------------------------
proc showsorted
getstuff
color (54)
cls
var temp1 : string
var temp2 : string
var temp3 : string
var temp4 : int
var temp5 : string
for x : 1 .. num
for i : 1 .. num - 1
if name (i) > name (i + 1) then
temp1 := name (i)
name (i) := name (i + 1)
name (i + 1) := temp1
temp2 := company (i)
company (i) := company (i + 1)
company (i + 1) := temp2
temp3 := model (i)
model (i) := model (i + 1)
model (i + 1) := temp3
temp4 := experience (i)
experience (i) := experience (i + 1)
experience (i + 1) := temp4
temp5 := phone (i)
phone (i) := phone (i + 1)
phone (i + 1) := temp5
end if
end for
end for
for i2 : 1 .. upper (name)
locate (2 + i2, 5)
put name (i2)
locate (2 + i2, 23)
put phone (i2)
end for
%Pic.Draw (picID4, 400, 0, picCopy)
locate (10, 10)
put "" ..
put "" ..
put "" ..
put "SORTED!" ..
put "" ..
put "Hit a key to return to the menu"
getch (main)
end showsorted
%------------------------------------------------------------------------------------------
proc menu
colorback (7)
cls
color (7)
% Pic.Draw (pic, 20, 250, picCopy)
%Pic.Draw (picID, 600, 50, picCopy)
Draw.Text ("FREESKIERS", 260, 310, font2, 42)
Draw.Text ("1) Display all riders, companies and thier weapon(s) of choice", 25, 200, font1, 50)
Draw.Text ("2) Average number of days on the snow last year", 25, 184, font1, 50)
Draw.Text ("3) Phone Numbers (Alphabetically) also sorts everything else", 25, 169, font1, 50)
Draw.Text ("4) Skier with most experience", 25, 154, font1, 50)
Draw.Text ("5) Skier with least experience", 25, 139, font1, 50)
Draw.Text ("6) Add a skier", 25, 124, font1, 50)
Draw.Text ("7) Delete a skier", 25, 109, font1, 50)
Draw.Text ("8) Quit", 25, 94, font1, 50)
end menu
%------------------------------------------------------------------------------------------
%values
%------------------------------------------------------------------------------------------
loop
menu
get choice
%------------------------------------------------------------------------------------------
if choice = 1 then
displayall
end if
%------------------------------------------------------------------------------------------
if choice = 2 then
average
end if
%------------------------------------------------------------------------------------------
if choice = 3 then
showsorted
end if
%------------------------------------------------------------------------------------------
if choice = 4 then
mostexperience
end if
%------------------------------------------------------------------------------------------
if choice = 5 then
leastexperience
end if
%------------------------------------------------------------------------------------------
if choice = 6 then
addstuff
savestuff
end if
%------------------------------------------------------------------------------------------
if choice = 7 then
deletestuff
savestuff
end if
%------------------------------------------------------------------------------------------
exit when choice = 8
%------------------------------------------------------------------------------------------
end loop |