package computerlab;
import java.util.Scanner;
public class ComputerLab {
private String building_name;
private int room_number;
private int number_of_seats;
private int working_computers;
ComputerLab(){
}
ComputerLab(String b, int r, int n, int w){
building_name = b;
room_number = r;
number_of_seats = n;
working_computers = w;
}
ComputerLab createComputerLab(){
Scanner scan = new Scanner(System.in);
System.out.println("Enter building name");
String b = scan.next();
System.out.println("Enter room number");
int r = scan.nextInt();
System.out.println("Enter number of working computers ");
int w = scan.nextInt();
System.out.println("Enter number of seats ");
int n = scan.nextInt();
ComputerLab lab = new ComputerLab(b, r, n, w);
return lab;
}
public void show(){
System.out.printf("Building Name: %s\nRoom number: %d\n", building_name,room_number);
System.out.printf("Number of seats: %d\nWorking Computers: %d\n", number_of_seats,working_computers);
}
void displayAllRooms(){
ComputerLab [] lab = new ComputerLab[2];
System.out.println("Applications Development Foundations:");
for(int i=0; i<2; i++){
ComputerLab compute = new ComputerLab();
lab[i] = compute.createComputerLab();
}
for(int i=0; i<2; i++){
lab[i].show();
}
}
public static void main(String[] args) {
ComputerLab lab = new ComputerLab();
lab.displayAllRooms();
}
}
Comments
Leave a comment