шпаргалки
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

2 years ago
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dev_j2022_2;
/**
*
* @author denis
*/
public class Device {
private int length;
private int width;
private int height;
public Device(){
length = 9;
width = 9;
height = 9;
}
public Device(int length, int width) {
this.length = length;
this.width = width;
}
public Device(int length, int width, int height) {
this.length = length;
this.width = width;
this.height = height;
}
public int getLength(){
return length;
}
public void setLength(int length){
if(length>0) this.length = length;
else throw new IllegalArgumentException("Значение length должно быть больше 0");
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public void print(){
System.out.println("Device: demention=" + length + "/" + width + "/" + height);
}
public void printAll(Device[] devices){
for(int i=0 ; i<devices.length ; i++){
devices[i].print();
}
}
}