Computer Science, asked by hardiknarain4859, 1 year ago

Create a class called compartment which represents the ship compartments with attributes like height, width and breadth.

Answers

Answered by sailorking
0

Answer:

The program is written in java:-

import java . io . * ;

public class compartment

{

          float height ;

          float width ;

          float breadth;

     public compartment( float height , float width , float breadth )

      {

              height=this.height ;

              width=this.width ;

              breadth=this.breadth ;

       }

}

Explanation:

In this program, the data members of the class are declared and a constructor is declared, where the members of the classes are initialized.

Similar questions