You are on page 1of 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace try311
{
internal class SafeLock
{
private bool locked;
private int password;
public void setPass(int password )
{
password = this.password;
}
public int getPass()
{
return password;
}
public void setLock(bool locked)
{
this.locked = locked;
}
public bool getLock()
{
return this.locked;
}

public SafeLock() {

password = 0000;
this.locked = true;

}
public SafeLock( int password)
{
this.password = password;
this.locked = true;

}
public void Lock(){
locked=true;
}
public void unlock(int password)
{
if (this.password == password)
{
locked = false;
Console.WriteLine("the password is incorrect");
} else

Console.WriteLine("Incoorect Password,Try Again");


}

static void Main(string[] args)


{
SafeLock s= new SafeLock();
Console.WriteLine("enter your own password");
int password =Int32.Parse( Console.ReadLine());

s.getPass();
s.setPass(password);
s.setLock(true);
try
{
s.unlock(1123);
Console.WriteLine("CORRECT PASSWORD");
}catch(FormatException ex)
{
Console.WriteLine(ex.Message);
}

Console.WriteLine("safe locked" + s.getLock());

}
}
}

You might also like