0% found this document useful (0 votes)
3 views4 pages

Exp 10

The document outlines the implementation of a modified Supply Chain Management System (SCMS) that enhances login functionality through a centralized LoginManager, dynamic user role creation, and real-time updates. Backend and frontend code changes are detailed, along with unit tests for validating the implementation. The system has been successfully tested for various scenarios, achieving the desired improvements in user experience and scalability.

Uploaded by

sharmila210604
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Exp 10

The document outlines the implementation of a modified Supply Chain Management System (SCMS) that enhances login functionality through a centralized LoginManager, dynamic user role creation, and real-time updates. Backend and frontend code changes are detailed, along with unit tests for validating the implementation. The system has been successfully tested for various scenarios, achieving the desired improvements in user experience and scalability.

Uploaded by

sharmila210604
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EXP.

NO:10
DATE: IMPLEMENTATION OF MODIFIED SYSTEMS

Aim:
To implement the modified system and test it for various scenarios.

Modification Description:
In the Supply Chain Management System (SCMS), enhancements were made to
streamline login functionality and improve user experience. A centralized LoginManager
now handles all login validations, ensuring consistency and efficient session management.
User roles are dynamically created using the factory pattern, enabling flexibility and
simplifying the addition of new roles. Real-time login updates are implemented using an
event-driven approach, ensuring instant UI reflection of login states and user types. These
changes enhance system scalability, simplify debugging, and provide a seamless user
experience by ensuring accurate and timely updates, making the SCMS more adaptable
and user-friendly.

Implementation:
Backend Implementation
The backend was modified to incorporate centralized login validation, dynamic role creation,
and event-driven updates.
Code Changes in LoginManager.java

public class LoginManager {


private static LoginManager instance;
private LoginManager() {
// Private constructor to ensure a single instance}
public static LoginManager getInstance() {
if (instance == null) {
instance = new LoginManager(); }
return instance;}
public boolean validateCredentials(String username, String password) {
// Validate user credentials against the database
return true; }}

Code Changes in UserFactory.java:

public class UserFactory {


public static User createUser(String role, String details) {
switch (role) {
case "Admin":
return new AdminUser(details);
case "Employee":
return new EmployeeUser(details);
default:
return new GuestUser(details); }}}

Code Changes in LoginNotifier.java:

import java.util.ArrayList;
import java.util.List;
interface Observer {
void update(String message);}
class LoginNotifier {
private List<Observer> observers = new ArrayList<>();
public void addObserver(Observer observer) {
observers.add(observer);}
public void notifyObservers(String message) {
for (Observer observer : observers) {
observer.update(message); }}}

Frontend Implementation:
The frontend was enhanced to reflect login status updates in real-time.
Code Changes in LoginStatusApp.java (Main Java Class):

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Login Status App");
loginStatusLabel = new Label("Not Logged In");
Button loginButton = new Button("Login");
loginButton.setOnAction(event -> {
// Simulating a login process
LoginNotifier notifier = new LoginNotifier();
LoginObserver observer = new LoginObserver();
notifier.addObserver(observer);
notifier.notifyObservers("Logged In as Admin");
});
VBox layout = new VBox(10);
layout.getChildren().addAll(loginStatusLabel, loginButton);
Scene scene = new Scene(layout, 300, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
public static class LoginNotifier {
private List<Observer> observers = new ArrayList<>();
public void addObserver(Observer observer) {
observers.add(observer); }
public void notifyObservers(String message) {
for (Observer observer : observers) {
observer.update(message); }}}
public interface Observer {
void update(String message); }}

Testing
Unit Tests Using JUnit
1. Create Test File: LoginManagerTest.java

public class LoginManagerTest {


@Test
public void testSingletonInstance() {
LoginManager instance1 = LoginManager.getInstance();
LoginManager instance2 = LoginManager.getInstance();
assertSame(instance1, instance2, "Both instances should be the same");}
@Test
public void testLoginValidation() {
LoginManager manager = LoginManager.getInstance();
assertTrue(manager.validateCredentials("user", "password"), "Validation
should succeed"); }}

2. Test File: UserFactoryTest.java

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class UserFactoryTest {
@Test
public void testAdminCreation() {
User user = UserFactory.createUser("Admin", "Admin Details");
assertTrue(user instanceof AdminUser, "User should be of type AdminUser");}
@Test
public void testEmployeeCreation() {
User user = UserFactory.createUser("Employee", "Employee Details");
assertTrue(user instanceof EmployeeUser, "User should be of type
EmployeeUser"); }}
OUTPUT:

Description Allotted Marks Obtained Marks

Preparation 20

Design/Implementation 20

Viva 15
Output 10
Record 10

Total 75

RESULT:
Thus, the modified system has been implemented and tested for various scenarios
successfully.

You might also like