I have a little code in which the purpose is to check the username and see if it exists in an array and the age to check if it is of legal age. If it is, you are authorized to enter the system.
The code is not finished yet but my doubt is that I have a type method String
that receives a parameter called name
that is in another class and is inherited through the main class called MyName
I have two fields defined private
(I should define them like this or public because I will use them the method of the other class), well then in the main class I define a constructor by which to define (initialize) by default the values there is my other problem I have two objects a String object and another ID type I should define them like this or how ?
Here is the code so you can see what I have:
main class
/*Proposito del programa:
el proposito del programa es verificar el name del usuario y ver si exsite en un array y la edad
verificar si es mayor de edad si lo es es autorizado a entrar al sistema.
*/
public Class MyClass extends Methods {
public static void main(String[]args) {
//Campos
private String name;
private int edad;
//Creo los objetos name(nombre) y edad(la edad del usuario)
String user = new String();
id edad = new id();
/* Mi problema es aqui en los objetos deberia crearlos asi o como ?*/
//Constructor
public MyClass {
user.Getname = "Gilberto quintero";
}
Scanner entrada = new Scanner(System.in);
}
}
the other class
public Class Methods {
public String Getname(String name) {
System.out.println("Hola bienvenido a"+name);
}
}
There are some errors.
I show you an example more or less so that you can notice and expand to your needs
Example:
The MyClass class
The Methods class
Obs:
I didn't quite understand your code and what you put in the purpose what I could do with two simple Java classes.
User.java
Application.java
It doesn't directly answer your question but I hope it helps you.
Although it has been difficult for me to understand what you are asking for, I think this is the most correct according to your needs. I have commented the code in such a way that I hope you will understand the working of the program smoothly.
Method class:
Class MyName that inherits from Methods the method that searches the array
I hope it will help you and clarify the concepts. Any questions you have ask!