OOP Case Study
OOP Case Study
Program :
package javaassignment;
import java.util.*;
// Object variables
private String name;
private String location;
private int capacity;
private int currentVisitors;
// Constructor
public Mall(String name, String location, int capacity) {
this.name = name;
this.location = location;
this.capacity = capacity;
this.currentVisitors = 0;
mallCount++;
}
// Add visitors
System.out.println("Enter the number of visitors to add:");
int visitorsToAdd = scanner.nextInt();
mall.addVisitors(visitorsToAdd);
// Remove visitors
System.out.println("Enter the number of visitors to remove:");
int visitorsToRemove = scanner.nextInt();
mall.removeVisitors(visitorsToRemove);
// Display mall information again
System.out.println("Updated Mall Information:");
mall.displayMallInfo();
// Close scanner
scanner.close();
}
}
H
Output