Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.List;
- public class Centrala {
- private Regał[] regały;
- int max_regał, max_półka, max_slot; // numerowane od 0 do max-1;
- public Centrala(int ile_regałów, int ile_półek, int ile_slotów) {
- regały = new Regał[ile_regałów];
- for (int i = 0; i < ile_regałów; i++) {
- regały[i] = new Regał(ile_półek, ile_slotów);
- }
- }
- public boolean WstawModuł(Slot slot, Moduł moduł) { // zwraca false gdy slot jest zajęty
- return slot.WstawModuł(moduł);
- }
- public void UsuńModuł(Slot slot) {
- slot.UsuńModuł();
- }
- public void WłączModuł(Moduł moduł) {
- moduł.Włącz();
- }
- public void WyłączModuł(Moduł moduł) {
- moduł.Wyłącz();
- }
- public void WypiszTyp(int typ) {
- for (int i = 0; i < max_regał; i++) {
- for (int j = 0; j < max_półka; j++) {
- for (int k = 0; k < max_slot; k++) {
- Slot s = GetSlot(i,j,k);
- if(s.GetModuł().GetTyp() == typ) {
- System.out.println(s.GetModuł().ToString());
- }
- }
- }
- }
- }
- public void WypiszCentrala() {
- for (int i = 0; i < max_regał; i++) {
- for (int j = 0; j < max_półka; j++) {
- for (int k = 0; k < max_slot; k++) {
- Slot s = GetSlot(i,j,k);
- System.out.println(s.GetModuł().ToString());
- }
- }
- }
- }
- public void WypiszRegał(int regał) {
- for (int i = 0; i < max_regał; i++) {
- for (int j = 0; j < max_półka; j++) {
- for (int k = 0; k < max_slot; k++) {
- Slot s = GetSlot(i,j,k);
- if(i == regał) {
- System.out.println(s.GetModuł().ToString());
- }
- }
- }
- }
- }
- public void WypiszPółkę(int regał, int półka) {
- for (int i = 0; i < max_regał; i++) {
- for (int j = 0; j < max_półka; j++) {
- for (int k = 0; k < max_slot; k++) {
- Slot s = GetSlot(i,j,k);
- if(i == regał && j == półka) {
- System.out.println(s.GetModuł().ToString());
- }
- }
- }
- }
- }
- public Slot GetSlot(int regał, int półka, int slot) {
- if (regał >= max_regał) {
- return null;
- }
- if (półka >= max_półka) {
- return null;
- }
- if (slot >= max_slot) {
- return null;
- }
- return regały[regał].GetPółka(półka).GetSlot(slot);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement