Open paulamitjava opened 5 years ago
// User Login Authentication
// View public class LoginAuthetication {
public static void main(String[] args) {
BusinessLogic ref = new BusinessLogic();
ref.myLogic();
}
}
// Controller public class BusinessLogic {
UserDAO userDAORef;
public void myLogic() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter ID : ");
int id = sc.nextInt(); // 1000
System.out.println("Enter Password : ");
String pwd = sc.next();
User refUser = new User();
refUser.setUserID(id); // 1000
refUser.setUserPWD(pwd);
userDAORef = new UserDAO();
boolean status = userDAORef.userAuthentication(refUser);
if (status==true) {
System.out.println("Login Success!!");
} else {
System.out.println("Login Fail!!");
}
}
}
// DAO (Data Access Object) public class UserDAO {
boolean status;
User userRef;
public boolean userAuthentication(User ref) {
if (ref.getUserID()==100 && ref.getUserPWD().equals("admin"))
{
status =true;
}
else {
status = false;
}
return status;
}
}
// Model public class User {
private int userID;
private String userPWD;
public int getUserID() {
return userID;
}
public void setUserID(int userID) {
this.userID = userID;
}
public String getUserPWD() {
return userPWD;
}
public void setUserPWD(String userPWD) {
this.userPWD = userPWD;
}
}
// User Defined Array Example
class Person{
String name; // global variable
int mobile; // global variable
public Person(String name, int mobile) { // constructor
this.name=name;
this.mobile=mobile;
}
@Override
public String toString() { // converts object to string
return name + " "+mobile;
}
} // end of Person
public class ArrayExample {
void arrayDisplay(String myArray[]) {
for (int i = 0; i < myArray.length; i++) {
System.out.println(myArray[i]);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("How many records you want to store : ");
int number = sc.nextInt(); // 5
Person p[] = new Person[number]; // 5
for (int i = 0; i < p.length; i++) {
System.out.println("Enter Name : ");
String name = sc.next();
System.out.println("Enter Mobile : ");
int mobile = sc.nextInt();
p[i] = new Person(name,mobile); // storing data to an array
}
for (Person person : p) {
System.out.println(person); // retrieving data from an array
}
}
}
// ATM Application
package atm_project;
import java.util.Scanner;
class DBS{
}
public class DBS_ATM {
}