Skip to content
Snippets Groups Projects
Commit b7778549 authored by AB8057's avatar AB8057
Browse files

Upload New File

parent bec33738
No related branches found
No related tags found
No related merge requests found
#some code to test the employee struct and functions:
defmodule Test do
#create an employee
def newEmployee do
firstNames = ["Jake", "Hannah", "Raul", "Filip", "Sumiko", "Terry", "Natalia"]
lastNames = ["Fuller", "Graham", "Puistola", "Yamaha", "Minou", "Taffel", "Johansson"]
#calling the randomName function
fName = randomName(firstNames)
lName = randomName(lastNames)
#creating the employee with the randomized name
Employee.new_employee(fName, lName)
end
def randomName(names) do
random_index = :rand.uniform(length(names))
Enum.at(names, random_index)
end
#tests for promoting and demoting the employee
def runTest() do
#creating an employee
employee = newEmployee()
id = employee.id_number
IO.inspect employee
#let's promote the created employee
promoted_employee = Employee.promote(employee)
IO.puts "Promoted Employee:"
IO.inspect promoted_employee
#let's promote the created employee even more
promoted_employee = Employee.promote(promoted_employee)
IO.puts "Promoted Employee Further:"
IO.inspect promoted_employee
#then let's demote the employee
demoted_employee = Employee.demote(promoted_employee)
IO.puts "Demoted Employee:"
IO.inspect demoted_employee
#and again
demoted_employee = Employee.demote(demoted_employee)
IO.puts "Demoted Employee Again:"
IO.inspect demoted_employee
end
end
#run tests
Test.runTest()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment