Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Driver class called MarkeBuilding that only has a main() method, and th

ID: 656824 • Letter: C

Question

Create a Driver class called MarkeBuilding that only has a main() method, and the main() method does the following takes in order. Asks the user to enter, on separate lines, the name, the square footage and the number of classrooms for a building to be built. Creates a Building object named the Building using the Building class (defined in the last problem) with the information given. Prits out what the average room size would be for the Building and prints out the abbreviated name of the building along with the average room size. Changes the square footage of the Building by doubling it, and then points out when the average room size would be if the building had the square footage.

Explanation / Answer

// MakeBuilding generates a building with a random shape, size, number of rooms, and floors

import acm.graphics.*;
import acm.program.*;
import acm.util.RandomGenerator;
import java.awt.*;

// GraphicsProgram is part of the acm library
public class MakeBuilding extends GraphicsProgram {

   // These are being used in the full code
   public static final int WALL_THICKNESS = 5;
   public static final int ROUND_CORNER = 30;
  
   public MakeBuilding(int posX, int posY) {
      
       // Random value for room size, between 20 and 100
       int roomWidth = randGen.nextInt(20, 100);
       int roomHeight = randGen.nextInt(20, 100);
      
       GRect myRectangle = new GRect(posX, posY, roomWidth, roomHeight);
       add(myRectangle);
  

   }
  
   // Instance variables
   private RandomGenerator randGen = RandomGenerator.getInstance();  
}


// World populates the graphics canvas with buildings provided by the MakeBuilding class

import acm.graphics.*;
import acm.program.*;
import acm.util.RandomGenerator;
import java.awt.*;

public class World extends GraphicsProgram {
  
   // Width and height of the application window
   public static final int APPLICATION_WIDTH = 400;
   public static final int APPLICATION_HEIGHT = 400;

   // run is part of the acm library
   public void run() {
      
  
       MakeBuilding newBuilding = new MakeBuilding(100, 100);
   }      
}