Question

The following BuildingApplication class is incomplete. You need to complete the missing lines of codes in:...

The following BuildingApplication class is incomplete. You need to complete the missing lines of codes in:

 inner class- Verification

 main method

Note: Assume that the building occupies the middle of the plot horizontally and vertically. To approve a building application, a building needs to provide a minimum clearance of 1m from the edge of the plot. i.e., the difference between plot width and building width should be at least 2m; the difference between the plot length and building length should be at least 2m.

public class BuildingApplication

{ double plotLength;

double plotWidth;

double buildingLength;

double buildingWidth; boolean approved = false;

public BuildingApplication (double plotLength, double plotWidth, double buildingLength, double buildingWidth)

{ this.plotLength = plotLength;

this.plotWidth = plotWidth;

this.buildingLength = buildingLength;

this.buildingWidth = buildingWidth; }

/inner class class Verification

{ boolean objection ;

private static final double MINIMUM_REQUIRED = 2.0;

//constructor

public Verification()

{ objection = false; }

// end of constructor- Verification

boolean check()

{ // to return true if there is a minimum clearance of 1m in all sides of the building //Missing lines of codes have to be completed }

// end of check method }

// end of inner class

public void displayApproval()

{ Verification test = new Verification();

approved = test.check();

if(approved)

System.out.println("Building plan Approved");

else

System.out.println("Building plan Rejected");}

public static void main(String [] args)

{ /* Create two BuildingApplication objects and test whether they are approved or not. * You need to create one Building object that can be approved and the other that *cannot be approved */ //Missing lines of codes have to be completed }

// end of main method }

// end of BuildingApplication clas

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Bean class

package sample1;

public class BuildingApplication
{
double plotLength;
double plotWidth;
double buildingLength;
public double getPlotLength() {
   return plotLength;
}
public void setPlotLength(double plotLength) {
   this.plotLength = plotLength;
}
public double getPlotWidth() {
   return plotWidth;
}
public void setPlotWidth(double plotWidth) {
   this.plotWidth = plotWidth;
}
public double getBuildingLength() {
   return buildingLength;
}
public void setBuildingLength(double buildingLength) {
   this.buildingLength = buildingLength;
}
public double getBuildingWidth() {
   return buildingWidth;
}
public void setBuildingWidth(double buildingWidth) {
   this.buildingWidth = buildingWidth;
}
double buildingWidth;
boolean approved = false;
public BuildingApplication (double plotLength, double plotWidth, double buildingLength, double buildingWidth)
{
   this.plotLength = plotLength;
this.plotWidth = plotWidth;
this.buildingLength = buildingLength;
this.buildingWidth = buildingWidth;
}

class Verification
{
boolean objection ;
private static final double MINIMUM_REQUIRED = 2.0;

//constructor
public Verification()
{ objection = false; }
// end of constructor- Verification
boolean check()
{
if(plotLength-buildingLength>=MINIMUM_REQUIRED&&plotWidth-buildingWidth>=MINIMUM_REQUIRED){
     
   objection= true;
     
}
else objection=false;
return objection;
}
}
public void displayApproval()
{
   Verification test = new Verification();
approved = test.check();
if(approved)
System.out.println("Building plan Approved");
else
System.out.println("Building plan Rejected");
}
}

//Test driver class

package sample1;

public class test{
public static void main(String [] args)
{
   BuildingApplication ba1=new BuildingApplication(102.0,52.0,101.0, 51.0);
   BuildingApplication ba2=new BuildingApplication(104.0,54.0,102.0, 52.0);
   ba1.displayApproval();
   ba2.displayApproval();
}
}

Add a comment
Know the answer?
Add Answer to:
The following BuildingApplication class is incomplete. You need to complete the missing lines of codes in:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Language: Java Write a class named ColoredRectangle that extends the Rectangle class (given below). The...

    Programming Language: Java Write a class named ColoredRectangle that extends the Rectangle class (given below). The ColoredRectangle class will have an additional private String field named Color. The ColoredRectangle class should have four constructors: a no-arg constructor; a three-arg constructor; a two-arg constructor that accepts a Rectangle object and a color; and a copy constructor. The ColoredRectangle class should have an Equals and toString methods. The ColoredRectangle class should have mutators and accessors for all three fields. public class Rectangle...

  • What is the output for the following program codes? a) [ 0.5 Mark ] class A...

    What is the output for the following program codes? a) [ 0.5 Mark ] class A { int i; } class B extends A { int j; void display() { super.i = j + 1; System.out.println(j + " " + i); }} class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); }} OUTPUT: b) [ 0.5 Mark ] class Parent { public void getBike(){ System.out.println("Suzuki Bike"); }} class Child extends Parent {...

  • Complete the following Java program by writing the missing methods. public class 02 { public static...

    Complete the following Java program by writing the missing methods. public class 02 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter a number: int n = scan.nextInt(); if (isOdd (n)) { //Print n to 1 System.out.println("Print all numbers from "+n+" to 1"); printNumToOne (n); } else { System.out.println(n + " is //End of main()

  • In Java Create a testing class that does the following to the given codes below: To...

    In Java Create a testing class that does the following to the given codes below: To demonstrate polymorphism do the following: Create an arraylist to hold 4 base class objects Populate the arraylist with one object of each data type Code a loop that will process each element of the arraylist Call the first ‘common functionality’ method Call the second ‘common functionality’ method Call the third ‘common functionality’ method Verify that each of these method calls produces unique results Call...

  • 12. Predict the output generated at the marked println lines in the following program. The program...

    12. Predict the output generated at the marked println lines in the following program. The program makes use of the class Employee that is also given. Please enter your answers in the space provided below the code. public class Employee { private String name; private double salary; public Employee(String name, double salary) { this.name = name; this.salary = salary; } public String getName() { return name; } public double getSalary() { return salary; } public void raiseSalary(double percent) { double...

  • This code is in java. Create a Java class that has the private double data of length, width, and price. Create the gets...

    This code is in java. Create a Java class that has the private double data of length, width, and price. Create the gets and sets methods for the variables. Create a No-Arg constructor and a constructor that accepts all three values. At the end of the class add a main method that accepts variables from the user as input to represent the length and width of a room in feet and the price of carpeting per square foot in dollars...

  • What is the missing keyword in the program below? public class Batman { public static int...

    What is the missing keyword in the program below? public class Batman { public static int minFunction(int n1, int n2) { int min; if (n1 > n2) min = n2; else min = n1; return min; //This is the value that will be returned from the minFunction method. //The value after the keyword return must match the return type from the method header. Ours is OK because they are both int. } // end the public method named minFunction }...

  • easy question but i am confused. someone help Consider the following Java classes: class OuterClass {...

    easy question but i am confused. someone help Consider the following Java classes: class OuterClass { static class InnerClass { public void inner Method({ System.out.println("This is my inner class"); public static void outer Method{ System.out.println("This is my outer class"); public class OuterClass Test{ public static void main(String args[]) { Complete the class OuterClass Test to produce as output the two strings in class OuterClass. What are the outputs of your test class?

  • Show the output of running the class Test in the following code lines: interface A {...

    Show the output of running the class Test in the following code lines: interface A { void print (); } class C ( class B extends C implements A { public void print() { } } class Test { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); w class Test { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b...

  • Using your Dog class from earlier this week, complete the following: Create a new class called...

    Using your Dog class from earlier this week, complete the following: Create a new class called DogKennel with the following: Instance field(s) - array of Dogs + any others you may want Contructor - default (no parameters) - will make a DogKennel with no dogs in it Methods: public void addDog(Dog d) - which adds a dog to the array public int currentNumDogs() - returns number of dogs currently in kennel public double averageAge() - which returns the average age...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT