-
Notifications
You must be signed in to change notification settings - Fork 9
/
ArrangeShips.java
1600 lines (1470 loc) · 45.6 KB
/
ArrangeShips.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Jeka on 15.10.2014.
*/
public class ArrangeShips extends FieldFrame {
private List<Ship> MyShips;
private List<Integer> ArrangeShips;
private JButton goButton;
private static final int[] LENGTH_OF_SHIPS={1,1,1,1,2,2,2,3,3,4};
public ArrangeShips(){
MyShips=new ArrayList<Ship>();
ArrangeShips=new ArrayList<Integer>();
goButton=new JButton("Go");
goButton.setEnabled(false);
JPanel goButtonPanel=new JPanel();
goButtonPanel.add(goButton);
goButtonPanel.setLayout(new BoxLayout(goButtonPanel, BoxLayout.Y_AXIS));
goButtonPanel.setPreferredSize(new Dimension(50,275));
this.setName("Player2");
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.getContentPane().add(goButtonPanel);
this.setSize(375,275);
pack();
this.addA1Listener(new A1Listener());
this.addA2Listener(new A2Listener());
this.addA3Listener(new A3Listener());
this.addA4Listener(new A4Listener());
this.addA5Listener(new A5Listener());
this.addA6Listener(new A6Listener());
this.addA7Listener(new A7Listener());
this.addA8Listener(new A8Listener());
this.addA9Listener(new A9Listener());
this.addA10Listener(new A10Listener());
this.addB1Listener(new B1Listener());
this.addB2Listener(new B2Listener());
this.addB3Listener(new B3Listener());
this.addB4Listener(new B4Listener());
this.addB5Listener(new B5Listener());
this.addB6Listener(new B6Listener());
this.addB7Listener(new B7Listener());
this.addB8Listener(new B8Listener());
this.addB9Listener(new B9Listener());
this.addB10Listener(new B10Listener());
this.addC1Listener(new C1Listener());
this.addC2Listener(new C2Listener());
this.addC3Listener(new C3Listener());
this.addC4Listener(new C4Listener());
this.addC5Listener(new C5Listener());
this.addC6Listener(new C6Listener());
this.addC7Listener(new C7Listener());
this.addC8Listener(new C8Listener());
this.addC9Listener(new C9Listener());
this.addC10Listener(new C10Listener());
this.addD1Listener(new D1Listener());
this.addD2Listener(new D2Listener());
this.addD3Listener(new D3Listener());
this.addD4Listener(new D4Listener());
this.addD5Listener(new D5Listener());
this.addD6Listener(new D6Listener());
this.addD7Listener(new D7Listener());
this.addD8Listener(new D8Listener());
this.addD9Listener(new D9Listener());
this.addD10Listener(new D10Listener());
this.addE1Listener(new E1Listener());
this.addE2Listener(new E2Listener());
this.addE3Listener(new E3Listener());
this.addE4Listener(new E4Listener());
this.addE5Listener(new E5Listener());
this.addE6Listener(new E6Listener());
this.addE7Listener(new E7Listener());
this.addE8Listener(new E8Listener());
this.addE9Listener(new E9Listener());
this.addE10Listener(new E10Listener());
this.addF1Listener(new F1Listener());
this.addF2Listener(new F2Listener());
this.addF3Listener(new F3Listener());
this.addF4Listener(new F4Listener());
this.addF5Listener(new F5Listener());
this.addF6Listener(new F6Listener());
this.addF7Listener(new F7Listener());
this.addF8Listener(new F8Listener());
this.addF9Listener(new F9Listener());
this.addF10Listener(new F10Listener());
this.addG1Listener(new G1Listener());
this.addG2Listener(new G2Listener());
this.addG3Listener(new G3Listener());
this.addG4Listener(new G4Listener());
this.addG5Listener(new G5Listener());
this.addG6Listener(new G6Listener());
this.addG7Listener(new G7Listener());
this.addG8Listener(new G8Listener());
this.addG9Listener(new G9Listener());
this.addG10Listener(new G10Listener());
this.addH1Listener(new H1Listener());
this.addH2Listener(new H2Listener());
this.addH3Listener(new H3Listener());
this.addH4Listener(new H4Listener());
this.addH5Listener(new H5Listener());
this.addH6Listener(new H6Listener());
this.addH7Listener(new H7Listener());
this.addH8Listener(new H8Listener());
this.addH9Listener(new H9Listener());
this.addH10Listener(new H10Listener());
this.addI1Listener(new I1Listener());
this.addI2Listener(new I2Listener());
this.addI3Listener(new I3Listener());
this.addI4Listener(new I4Listener());
this.addI5Listener(new I5Listener());
this.addI6Listener(new I6Listener());
this.addI7Listener(new I7Listener());
this.addI8Listener(new I8Listener());
this.addI9Listener(new I9Listener());
this.addI10Listener(new I10Listener());
this.addJ1Listener(new J1Listener());
this.addJ2Listener(new J2Listener());
this.addJ3Listener(new J3Listener());
this.addJ4Listener(new J4Listener());
this.addJ5Listener(new J5Listener());
this.addJ6Listener(new J6Listener());
this.addJ7Listener(new J7Listener());
this.addJ8Listener(new J8Listener());
this.addJ9Listener(new J9Listener());
this.addJ10Listener(new J10Listener());
}
//Listeners
//A1
private class A1Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(0);
a1.setBackground(Color.MAGENTA);
a1.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA1Listener(ActionListener a){
a1.addActionListener(a);
}
//A2
private class A2Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(1);
a2.setBackground(Color.MAGENTA);
a2.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA2Listener(ActionListener a){
a2.addActionListener(a);
}
//A3
private class A3Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(2);
a3.setBackground(Color.MAGENTA);
a3.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA3Listener(ActionListener a){
a3.addActionListener(a);
}
//A4
private class A4Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(3);
a4.setBackground(Color.MAGENTA);
a4.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA4Listener(ActionListener a){
a4.addActionListener(a);
}
//A5
private class A5Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(4);
a5.setBackground(Color.MAGENTA);
a5.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA5Listener(ActionListener a){
a5.addActionListener(a);
}
//A6
private class A6Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(5);
a6.setBackground(Color.MAGENTA);
a6.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA6Listener(ActionListener a){
a6.addActionListener(a);
}
//A7
private class A7Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(6);
a7.setBackground(Color.MAGENTA);
a7.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA7Listener(ActionListener a){
a7.addActionListener(a);
}
//A8
private class A8Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(7);
a8.setBackground(Color.MAGENTA);
a8.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA8Listener(ActionListener a){
a8.addActionListener(a);
}
//A9
private class A9Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(8);
a9.setBackground(Color.MAGENTA);
a9.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA9Listener(ActionListener a){
a9.addActionListener(a);
}
//A10
private class A10Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(9);
a10.setBackground(Color.MAGENTA);
a10.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addA10Listener(ActionListener a){
a10.addActionListener(a);
}
//B1
private class B1Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(10);
b1.setBackground(Color.MAGENTA);
b1.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB1Listener(ActionListener a){
b1.addActionListener(a);
}
//B2
private class B2Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(11);
b2.setBackground(Color.MAGENTA);
b2.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB2Listener(ActionListener a){
b2.addActionListener(a);
}
//B3
private class B3Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(12);
b3.setBackground(Color.MAGENTA);
b3.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB3Listener(ActionListener a){
b3.addActionListener(a);
}
//B4
private class B4Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(13);
b4.setBackground(Color.MAGENTA);
b4.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB4Listener(ActionListener a){
b4.addActionListener(a);
}
//B5
private class B5Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(14);
b5.setBackground(Color.MAGENTA);
b5.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB5Listener(ActionListener a){
b5.addActionListener(a);
}
//B6
private class B6Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(15);
b6.setBackground(Color.MAGENTA);
b6.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB6Listener(ActionListener a){
b6.addActionListener(a);
}
//B7
private class B7Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(16);
b7.setBackground(Color.MAGENTA);
b7.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB7Listener(ActionListener a){
b7.addActionListener(a);
}
//B8
private class B8Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(17);
b8.setBackground(Color.MAGENTA);
b8.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB8Listener(ActionListener a){
b8.addActionListener(a);
}
//B9
private class B9Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(18);
b9.setBackground(Color.MAGENTA);
b9.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB9Listener(ActionListener a){
b9.addActionListener(a);
}
//B10
private class B10Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(19);
b10.setBackground(Color.MAGENTA);
b10.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addB10Listener(ActionListener a){
b10.addActionListener(a);
}
//C1
private class C1Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(20);
c1.setBackground(Color.MAGENTA);
c1.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC1Listener(ActionListener a){
c1.addActionListener(a);
}
//C2
private class C2Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(21);
c2.setBackground(Color.MAGENTA);
c2.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC2Listener(ActionListener a){
c2.addActionListener(a);
}
//C3
private class C3Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(22);
c3.setBackground(Color.MAGENTA);
c3.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC3Listener(ActionListener a){
c3.addActionListener(a);
}
//C4
private class C4Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(23);
c4.setBackground(Color.MAGENTA);
c4.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC4Listener(ActionListener a){
c4.addActionListener(a);
}
//C5
private class C5Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(24);
c5.setBackground(Color.MAGENTA);
c5.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC5Listener(ActionListener a){
c5.addActionListener(a);
}
//C6
private class C6Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(25);
c6.setBackground(Color.MAGENTA);
c6.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC6Listener(ActionListener a){
c6.addActionListener(a);
}
//C7
private class C7Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(26);
c7.setBackground(Color.MAGENTA);
c7.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC7Listener(ActionListener a){
c7.addActionListener(a);
}
//C8
private class C8Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(27);
c8.setBackground(Color.MAGENTA);
c8.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC8Listener(ActionListener a){
c8.addActionListener(a);
}
//C9
private class C9Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(28);
c9.setBackground(Color.MAGENTA);
c9.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC9Listener(ActionListener a){
c9.addActionListener(a);
}
//C10
private class C10Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(29);
c10.setBackground(Color.MAGENTA);
c10.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addC10Listener(ActionListener a){
c10.addActionListener(a);
}
//D1
private class D1Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(30);
d1.setBackground(Color.MAGENTA);
d1.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD1Listener(ActionListener a){
d1.addActionListener(a);
}
//D2
private class D2Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(31);
d2.setBackground(Color.MAGENTA);
d2.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD2Listener(ActionListener a){
d2.addActionListener(a);
}
//D3
private class D3Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(32);
d3.setBackground(Color.MAGENTA);
d3.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD3Listener(ActionListener a){
d3.addActionListener(a);
}
//D4
private class D4Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(33);
d4.setBackground(Color.MAGENTA);
d4.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD4Listener(ActionListener a){
d4.addActionListener(a);
}
//D5
private class D5Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(34);
d5.setBackground(Color.MAGENTA);
d5.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD5Listener(ActionListener a){
d5.addActionListener(a);
}
//D6
private class D6Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(35);
d6.setBackground(Color.MAGENTA);
d6.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD6Listener(ActionListener a){
d6.addActionListener(a);
}
//D7
private class D7Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(36);
d7.setBackground(Color.MAGENTA);
d7.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD7Listener(ActionListener a){
d7.addActionListener(a);
}
//D8
private class D8Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(37);
d8.setBackground(Color.MAGENTA);
d8.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD8Listener(ActionListener a){
d8.addActionListener(a);
}
//D9
private class D9Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(38);
d9.setBackground(Color.MAGENTA);
d9.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD9Listener(ActionListener a){
d9.addActionListener(a);
}
//D10
private class D10Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(39);
d10.setBackground(Color.MAGENTA);
d10.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addD10Listener(ActionListener a){
d10.addActionListener(a);
}
//E1
private class E1Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(40);
e1.setBackground(Color.MAGENTA);
e1.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE1Listener(ActionListener a){
e1.addActionListener(a);
}
//E2
private class E2Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(41);
e2.setBackground(Color.MAGENTA);
e2.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE2Listener(ActionListener a){
e2.addActionListener(a);
}
//E3
private class E3Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(42);
e3.setBackground(Color.MAGENTA);
e3.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE3Listener(ActionListener a){
e3.addActionListener(a);
}
//E4
private class E4Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(43);
e4.setBackground(Color.MAGENTA);
e4.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE4Listener(ActionListener a){
e4.addActionListener(a);
}
//E5
private class E5Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(44);
e5.setBackground(Color.MAGENTA);
e5.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE5Listener(ActionListener a){
e5.addActionListener(a);
}
//E6
private class E6Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(45);
e6.setBackground(Color.MAGENTA);
e6.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE6Listener(ActionListener a){
e6.addActionListener(a);
}
//E7
private class E7Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(46);
e7.setBackground(Color.MAGENTA);
e7.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE7Listener(ActionListener a){
e7.addActionListener(a);
}
//E8
private class E8Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(47);
e8.setBackground(Color.MAGENTA);
e8.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE8Listener(ActionListener a){
e8.addActionListener(a);
}
//E9
private class E9Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(48);
e9.setBackground(Color.MAGENTA);
e9.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE9Listener(ActionListener a){
e9.addActionListener(a);
}
//E10
private class E10Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(49);
e10.setBackground(Color.MAGENTA);
e10.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addE10Listener(ActionListener a){
e10.addActionListener(a);
}
//F1
private class F1Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(50);
f1.setBackground(Color.MAGENTA);
f1.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF1Listener(ActionListener a){
f1.addActionListener(a);
}
//F2
private class F2Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(51);
f2.setBackground(Color.MAGENTA);
f2.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF2Listener(ActionListener a){
f2.addActionListener(a);
}
//F3
private class F3Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(52);
f3.setBackground(Color.MAGENTA);
f3.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF3Listener(ActionListener a){
f3.addActionListener(a);
}
//F4
private class F4Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(53);
f4.setBackground(Color.MAGENTA);
f4.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF4Listener(ActionListener a){
f4.addActionListener(a);
}
//F5
private class F5Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(54);
f5.setBackground(Color.MAGENTA);
f5.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF5Listener(ActionListener a){
f5.addActionListener(a);
}
//F6
private class F6Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(55);
f6.setBackground(Color.MAGENTA);
f6.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF6Listener(ActionListener a){
f6.addActionListener(a);
}
//F7
private class F7Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(56);
f7.setBackground(Color.MAGENTA);
f7.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF7Listener(ActionListener a){
f7.addActionListener(a);
}
//F8
private class F8Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(57);
f8.setBackground(Color.MAGENTA);
f8.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF8Listener(ActionListener a){
f8.addActionListener(a);
}
//F9
private class F9Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(58);
f9.setBackground(Color.MAGENTA);
f9.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF9Listener(ActionListener a){
f9.addActionListener(a);
}
//F10
private class F10Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(59);
f10.setBackground(Color.MAGENTA);
f10.setEnabled(false);
conditionForMakeShips(areCellsReady());
}
}
public void addF10Listener(ActionListener a){
f10.addActionListener(a);
}
//G1
private class G1Listener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
addCell(60);
g1.setBackground(Color.MAGENTA);
g1.setEnabled(false);
conditionForMakeShips(areCellsReady());