Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Box {
- static private double width;
- static private double length;
- static private double height;
- public Box() {
- this.width = 1.0;
- this.length = 1.0;
- this.height = 1.0;
- }
- public Box(double w, double l, double h) {
- if (w < 0)
- w = 1.0;
- if (h < 0)
- h = 1.0;
- if (l < 0)
- l = 1.0;
- width = w;
- height = h;
- length = l;
- }
- public static String toString(Box x) {
- return String.format("Width: %.2f Length: %.2f Height: %.2f",
- x.getWidth(),x.getLength(),x.getHeight());
- }
- public static void main(String[] args) {
- Box sample = new Box(43,57,3423);
- toString(sample);
- // System.out.printf("Width: %.2f Length: %.2f Height: %.2f%n",
- //sample.getWidth(),sample.getLength(),sample.getHeight());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement