Created
May 26, 2022 15:53
-
-
Save IacovColisnicenco/f3ac74e71ed7f362d4e5852e3ea8896a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util. *; | |
public class MyClass { | |
public static void main(String args[]) { | |
class User { | |
int age; | |
String name; | |
public void hasAccess() { | |
if(age>=18){ | |
System.out.println("Hello "+ name + ", access permited"); | |
}else if(age<18) { | |
System.out.println("Hello "+ name + ", access denied!"); | |
} | |
} | |
} | |
User anna = new User(); | |
anna.name = "Anna"; | |
anna.age = 17; | |
User iacov = new User(); | |
iacov.name = "Iacov"; | |
iacov.age = 34; | |
anna.hasAccess(); | |
iacov.hasAccess(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment