Add password example
This commit is contained in:
parent
83f65bd683
commit
50b4d192f3
2 changed files with 21 additions and 0 deletions
19
examples/basics/password.pl
Normal file
19
examples/basics/password.pl
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
login :-
|
||||||
|
getdata(_, _),
|
||||||
|
writeln('Welcome!').
|
||||||
|
login :-
|
||||||
|
repeat,
|
||||||
|
writeln('Sorry, you are not permitted.'),
|
||||||
|
getdata(_, _),
|
||||||
|
writeln('Welcome').
|
||||||
|
|
||||||
|
getdata(Name, Password) :-
|
||||||
|
write('Username: '),
|
||||||
|
read(Name),
|
||||||
|
write('Password: '),
|
||||||
|
read(Password),
|
||||||
|
user(Name, Password).
|
||||||
|
|
||||||
|
user(john, john1).
|
||||||
|
user(jimmy, jimmy1).
|
||||||
|
user(mary, mary1).
|
2
examples/basics/repeat.pl
Normal file
2
examples/basics/repeat.pl
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
repeat.
|
||||||
|
repeat :- repeat.
|
Reference in a new issue