-
Notifications
You must be signed in to change notification settings - Fork 0
/
draft.txt
6158 lines (4195 loc) · 134 KB
/
draft.txt
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
package test;
public class HelloDate {
public String line = "stroka";
public static void main(String[] args) {
System.out.print("Inside HelloDate");
//NewClass testObj1 = new NewClass();
}
}
/*
*
*
*
*
* for (Money s : Money.values()) { System.out.print(" " + s.ordinal() + "-ый "
* + s); }
*
*
* coin.PENNY = 0.01; coin.NICKEL = 0.05; coin.DIME=0.1F; coin.QUARTER = 0.25F;
* coin.HALF_DOLLAR = 0.5f; coin.SILVER=1;
*
*
*
*
* TestClass[] testArr = new TestClass[] {}; testArr = new TestClass[] { new
* TestClass(), new TestClass("arg2"), new TestClass("arg3") };
*
*
*
* int fang1, fang2; fang1 = tempMas[0] * 10 + tempMas[1]; fang2 = tempMas[2] *
* 10 + tempMas[3];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[1] * 10 + tempMas[0]; fang2 = tempMas[3] * 10 + tempMas[2];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[0] * 10 + tempMas[1]; fang2 = tempMas[3] * 10 + tempMas[2];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[1] * 10 + tempMas[0]; fang2 = tempMas[2] * 10 + tempMas[3];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[0] * 10 + tempMas[2]; fang2 = tempMas[1] * 10 + tempMas[3];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[0] * 10 + tempMas[2]; fang2 = tempMas[3] * 10 + tempMas[1];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[2] * 10 + tempMas[0]; fang2 = tempMas[1] * 10 + tempMas[3];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[2] * 10 + tempMas[0]; fang2 = tempMas[3] * 10 + tempMas[1];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[0] * 10 + tempMas[3]; fang2 = tempMas[1] * 10 + tempMas[2];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[0] * 10 + tempMas[3]; fang2 = tempMas[2] * 10 + tempMas[1];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[3] * 10 + tempMas[0]; fang2 = tempMas[1] * 10 + tempMas[2];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; }
*
* fang1 = tempMas[3] * 10 + tempMas[0]; fang2 = tempMas[2] * 10 + tempMas[1];
*
* if ((fang1 * fang2) == vampir) { System.out.println("ВАМПИР!" + vampir);
* return; } }
*
*
*
*
* static void method1(char tempC) { System.out.println("symbol " + tempC +
* " to binary : " + Integer.toBinaryString(tempC) + " " + (int) tempC); }
*
* static void methodForStrings(String sObj1, String sObj2) {
* System.out.println("sObj1 == sObj2 : " + (sObj1 == sObj2));
* System.out.println("sObj1 != sObj2 : " + (sObj1 != sObj2));
* System.out.println("equals : " + (sObj1.equals(sObj2))); }
*
* static String method2(int numbr1, int numbr2) { if (numbr1 > numbr2) return
* (" over "); else if (numbr1 < numbr2) return (" under "); else return
* (" equal "); }
*
* static void method3(int bound) { for (int i = 1; i <= bound; i++) for (int j
* = 1; j < i; j++) if (((i % j) == 0) && (j != 1)) j = i; else if (i == j + 1)
* System.out.print(i + " "); }
*
* static String method4(int number, int bottomBoard, int upperBoard) { if
* ((number < bottomBoard) || (number > upperBoard)) return
* "Ошибка!Введеное число,невходит в заданный промежуток"; return
* "Число входит в заданный диапозон значений!";
*
* }
*
* static int[] method6(int fourDigit) { int tempMas[] = new int[4]; tempMas[0]
* = fourDigit / 1000; fourDigit = (fourDigit - ((fourDigit / 1000) * 1000));
* tempMas[1] = fourDigit / 100; fourDigit = (fourDigit - ((fourDigit / 100) *
* 100)); tempMas[2] = fourDigit / 10; fourDigit = (fourDigit - ((fourDigit /
* 10) * 10)); tempMas[3] = fourDigit; return tempMas; }
*
* static void method5(int[] tempMas, int vampir) {
*
*
* class Dog { void bark() { System.out.print("woof "); }
*
* void bark(char c) { System.out.print("woof char " + c); }
*
* void bark(byte b) { System.out.print(" woof byte " + b); }
*
* void bark(short s) { System.out.print(" woof short " + s); }
*
* void bark(int i) { System.out.print(" woof int " + i); }
*
* void bark(long l) { System.out.print(" woof long " + l); }
*
* void bark(float f) { System.out.print(" woof float " + f); }
*
* void bark(double d) { System.out.print(" woof double " + d); }
*
* void testDog() { char chVal = 'z'; byte byteVal = -127; short shortVal =
* -111; int intVal = 0; long longVal = 11515; float floatVal = -152.22f; double
* doubleVal = 88999.0009d; bark(); bark(chVal); bark(byteVal); bark(shortVal);
* bark(intVal); bark(longVal); bark(floatVal); bark(doubleVal);
*
* }
*
* void info(char ch, int age) { System.out.println("сначала " + ch +
* " а уже потом " + age); }
*
* void info(int age, char ch) { System.out.println("сначала " + age +
* " а уже потом " + ch); } }
*
* class Cat { Cat(int i) { System.out.println("marker " + i); }
*
* void f1(int i) { System.out.println("f(" + i + ")"); }
*
* }
*
* class Cats { Cat testCat2 = new Cat(2); Cat testCat1; { testCat1 = new
* Cat(1);
*
* }
*
* Cats() { System.out.println("CATS()"); } // static Cat testCat2 = new Cat(2);
* }
*
* class DynamicArr { public static void main(String[] args) { for (String tempS
* : args) { System.out.print(tempS + " "); } } }
*
* class TestClass { TestClass() { System.out.print("constr() "); }
*
* TestClass(String tempStr) { System.out.print(tempStr + " "); } }
*
*
*
*
*
* Cats.testCat1.f1(99); Cats testObj = new Cats(); int[] a1 = { 1, 2, 3, 4, 5
* }; int[] a2; a2 = a1; for (int i = 0; i < a2.length; i++) a2[i] = a2[i] * 2;
* for (int i = 0; i < a1.length; i++) System.out.print(a1[i] + " ");
*
* // DynamicArr.main(new String[] { "arg1", "arg2", "arg3" });
**
* for (TestClass tempVal : testArr) { System.out.print(tempVal + " "); }
**
*
* // TempClass testObj = new TempClass("super-puper"); // testObj.lineOpr =
* "lineOpr"; // System.out.print(testObj.lineKonst + " " + testObj.lineOpr); //
*
*
* Dog testObj = new Dog(); // testObj.testDog(); // testObj.info('x', 0); //
* testObj.info(1,'Y');******* int massiv[] = new int[4];**for( int i =
* 1000;i<9999;i++) { massiv = method(i); method5(massiv, i);
* }*if(args[0]!=null) { int tempL = 0, tempR = 1, number = 0, temp = tempL +
* tempR; number = Integer.parseInt(args[0]); System.out.print(tempL + ", " +
* tempR + ", " + temp + ", "); while (number != temp) { tempL = tempR; tempR =
* temp; temp = tempL + tempR; System.out.print(temp + ", "); }
* }else*System.exit(1);
**/
/*
*
* int intMas[] = new int[10]; for (int i = 0; i < intMas.length; i++) {
* intMas[i] = i; }
*
* for (int x : intMas) { System.out.print(x + " "); }
*
* System.out.println();
*
* for (int x : intMas) { switch (x) { case 1: System.out.println("1"); break;
* case 2: System.out.println("2"); break; case 3: System.out.println("3");
* break; case 8: System.out.println("8"); break; case 9:
* System.out.println("9"); break; case 10: System.out.println("10"); break;
* default: System.out.println("ti sosqa"); break; } }
*
*
*
*
*
*
*/
/*
*
*
*
*
* System.out.println(true & true); System.out.println(true & false);
* System.out.println(false & true); System.out.println(false & false);
*
*
*
*
*/
/*
* Random objRand = new Random(100); int number = objRand.nextInt(100); for (;;)
* { System.out.println("rand number " + number + method(number, (number =
* objRand.nextInt(100))) + number); }
*/
//System.out.println(Character.digit('k', 2)); && || ! < > <= >= != == equals
/*
* method('A'); method('a'); method('Z'); method('z'); method('5'); method('.');
* method('&'); method('#'); method('?'); method('@'); method('ё'); method('Ё');
*/
// System.out.println(Character.MIN_RADIX + " " + Character.MAX_RADIX);
/*
* int intVar = -1;
*
* System.out.println(" origin : " + Integer.toBinaryString(intVar)); for (int i
* = 0; i < 31; i++) { System.out.println(" <<= : " +
* Integer.toBinaryString(intVar <<= 1)); } for (int i = 0; i < 31; i++) {
* System.out.println(" >>> : " + Integer.toBinaryString(intVar >>>= 1)); }
*/
// int secondVar = 0x0af1;
/*
* objStream.println((firstVar & secondVar));
* objStream.println(Integer.toBinaryString(firstVar | secondVar));
* objStream.println(Integer.toBinaryString(firstVar ^ secondVar));
*/
/*
* method(true); float varF = Float.MAX_VALUE; double varD = Double.MAX_VALUE;
*
* objStream.println(varF + " " + Float.floatToIntBits(varF));
* objStream.println(varD + " " + Double.doubleToLongBits(varD));
*/
/*
* int testInt = 0X11; objStream.println(Integer.valueOf(testInt)); long
* testLongX16 = 0x2fl; objStream.println(Long.toBinaryString(testLongX16));
* long testLongX8 = 021l; objStream.println(Long.toBinaryString(testLongX8));
*/
/*
* Random rand = new Random(); OutputCoin.method(rand.nextBoolean());
* OutputCoin.method(rand.nextBoolean()); OutputCoin.method(rand.nextBoolean());
* OutputCoin.method(rand.nextBoolean());
*/
// DateForFirstDrill tempObject = new DateForFirstDrill();
// Random rand = new Random(44);
/*
* Dog spot = new Dog(); Dog scruffy = new Dog(); spot.name = "spot"; spot.says
* = "ugh!"; scruffy.name = "scruffy"; scruffy.says = "fuck that!";
*/
/*
* Random rand = new Random(44); Data obj1 = new Data(); Short varShort = new
* Short((short) 1); int varIntValue = rand.nextInt(100) + 1; int testInt = 10;
*/
// System.out.println("Интежер "+tempObject.testInteger);
// System.out.println("Чар "+tempObject.testChar);
// СlassForMethod tempObjectForClass = new СlassForMethod();
// String lineForClass = "stroka";
/*
* objStream.println(spot.name + " says " + spot.says + " and " + scruffy.name +
* " says " + scruffy.says); Dog anotherDog = new Dog(); spot = anotherDog;
* objStream.println("== : " + (spot == anotherDog) + " " + spot + anotherDog);
* objStream.println("equals : " + (spot.equals(anotherDog)) + " " + spot +
* anotherDog);
*/
/*
* objStream.println(lineForClass); objStream.println("Скорость равна " +
* obj1.calc() + " км/ч"); objStream.println("short : " + varIntValue +
* "; varShort : " + varShort); testInt = testInt++ * testInt;
* objStream.println(testInt);
*/
// System.out.println("Строка занимает " +
// tempObjectForClass.storage(lineForClass) + " байт");
/*
* Integer temp = new Integer(100); Character ch = new Character('a');
* objStream.print(temp); objStream.print(ch);
*/
/*
* TestClass firstObj = new TestClass(); TestClass secondObj = new TestClass();
* TestClass thirdObj = new TestClass();
*/
/*
* TestClass.generalInt = 777; firstObj.generalInt = 100;
* System.out.println(TestClass.generalInt); secondObj.generalInt= 200;
* System.out.println(TestClass.generalInt); thirdObj.generalInt = 300;
* System.out.println(TestClass.generalInt); TestClass.generalInt = 777;
* System.out.println(TestClass.generalInt);
*/
/*
* System.out.println(); System.out.println(new Date());
* System.getProperties().list(System.out);
* System.out.println(System.getProperties());
* System.out.println(System.getProperty("user.name"));
* System.out.println(System.getProperty("java.library.path"));
*/
LITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELPLITTLEHELP
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
// interfaces/Cycles.java
// TIJ4 Chapter Interfaces, Exercise 18, page 342
/* Create a Cycle interface, with implementations Unicycle, Bicycle and
* Tricycle. Create factories for each type of Cycle, and code that uses
* these factories.
*/
import static org.greggordon.tools.Print.*;
interface Cycle {
void ride();
}
interface CycleFactory {
Cycle getCycle();
}
class Unicycle implements Cycle {
public void ride() { println("Ride Unicycle"); }
}
class UnicycleFactory implements CycleFactory {
public Cycle getCycle() {
return new Unicycle();
}
}
class Bicycle implements Cycle {
public void ride() { println("Ride Bicycle"); }
}
class BicycleFactory implements CycleFactory {
public Cycle getCycle() {
return new Bicycle();
}
}
class Tricycle implements Cycle {
Tricycle() { println("Tricycle()"); }
public void ride() { println("Ride Tricycle"); }
}
class TricycleFactory implements CycleFactory {
public Cycle getCycle() {
return new Tricycle();
}
}
public class Cycles {
public static void rideCycle(CycleFactory factory) {
Cycle c = factory.getCycle();
c.ride();
}
public static void main(String [] args) {
rideCycle(new UnicycleFactory());
rideCycle(new BicycleFactory());
rideCycle(new TricycleFactory());
}
}
1
Downloading1
ФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАФАБРИКАМ
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
import java.nio.*;
import java.util.*;
interface Cycle {
void ride();
}
interface CycleFactory {
Cycle GetCycle();
}
class Unicycle implements Cycle {
public void ride() {
Test.print("Unicycle");
}
}
class UnicycleFactory implements CycleFactory {
public Cycle GetCycle() {
return new Unicycle();
}
}
class Bicycle implements Cycle {
public void ride() {
Test.print("Bicycle");
}
}
class BicycleFactory implements CycleFactory {
public Cycle GetCycle() {
return new Bicycle();
}
}
class Tricycle implements Cycle {
// Tricycle() {}
public void ride() {
Test.print("Tricycle");
}
}
class TricycleFactory implements CycleFactory {
public Cycle GetCycle() {
return new Tricycle();
}
}
public class Test {
static void rideCycle(CycleFactory factory) {
Cycle c = factory.GetCycle();
c.ride();// создание обьекта,реализующего интерфейс
}
public static void main(String[] args) {
rideCycle(new UnicycleFactory());// здесь все обьекты,которые реализуют интерфейс(ride();,аждый свой)
rideCycle(new BicycleFactory());
rideCycle(new TricycleFactory());
}
public static void print(Object obj) {
System.out.println(obj);
}
public static void print() {
System.out.println();
}
public static void printnb(Object obj) {
System.out.print(obj);
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
import java.nio.*;
import java.util.*;
interface Coin {
void toss();
}
interface Cube {
void dice();
}
interface CoinFactory {
Coin GetCoin();
}
interface CubeFactory {
Cube GetCube();
}
class CoinGame implements Coin {// реализция интерфейса
public void toss() {
Random rand = new Random();
Test.print((rand.nextBoolean()) ? "tail" : "eagle");
};
}
class CubeGame implements Cube {
public void dice() { // реализция интерфейса
Random rand = new Random();
switch (rand.nextInt(5)) {
case 0:
Test.print("dropped 1 point");
break;
case 1:
Test.print("dropped 2 point");
break;
case 2:
Test.print("dropped 3 point");
break;
case 3:
Test.print("dropped 4 point");
break;
case 4:
Test.print("dropped 5 point");
break;
}
};
}
class CoinGameFactory implements CoinFactory {
public Coin GetCoin() {
return new CoinGame();
}
}
class CubeGameFactory implements CubeFactory {
public Cube GetCube() {
return new CubeGame();
}
}
public class Test {
static void rideCoin(CoinFactory factoryCoin) {
Coin objGameCoin = factoryCoin.GetCoin();// objGameCoin - тот смый обьект(важно!)
objGameCoin.toss();
}
static void rideCube(CubeFactory factoryCube) {
Cube objGameCube = factoryCube.GetCube(); // objGameCube - тот самый обьект(важно!)
objGameCube.dice();
}
public static void main(String[] args) {
// rideCoin(new CoinGameFactory());
// rideCube(new CubeGameFactory());
}
public static void print(Object obj) {
System.out.println(obj);
}
public static void print() {
System.out.println();
}
public static void printnb(Object obj) {
System.out.print(obj);
}
}
public class Outer1 {
class Inner {
Inner()
{ System.out.println("Inner()"); }
}
Outer1()
{ System.out.println("Outer1()"); }
// make an Inner from within a non-static method of outer class:
Inner makeInner() {
return new Inner();
}
public static void main(String[] args) {
Outer1 o = new Outer1();
Inner i = o.makeInner();
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ9ЗАДАНИЕ-СТАРННОЕ
interface Interface {
void method();
}
public class Outter {
public Interface methodInner(boolean b) {
if (b) {
class Inner implements Interface {
public void method() {
}
}
return new Inner();
}
return null;// !!
}
public static void main(String[] args) {
Outter obj = new Outter();
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
import static net.mindview.util.Print.*;
import java.util.*;
import typeinfo.pets.*;
import java.util.regex.*;
import net.mindview.util.*;
class TempClass {
public static Set<Character> vowell = new HashSet<Character>(
Arrays.asList('A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'));
public int search(String str) {
int countWordsVowell = 0;
int i = 0;
while (i != str.length()) {
if (vowell.contains(str.charAt(i++)))
countWordsVowell++;
}
return countWordsVowell;
}
}
public class ListFeatures {
public static void main(String[] args) {
TempClass tempObject = new TempClass();
List<String> words = new ArrayList<String>();// String.CASE_INSENSITIVE_ORDER - это компоратор
words.addAll(new TextFile("D:\\eclipse\\workspace\\testProject\\src\\testProject\\JavaProg.java", "\\W+"));//
int result = 0;
for (String temp : words) {
result += tempObject.search(temp);
}
print(result);
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
import static testProject.Test.*;
import java.util.Random;
class ConectionManager {
private static int i = 0;
private static Connection[] connectionMas = new Connection[5];
public static Connection giveMeConnection() {
if (i <= 4) {
connectionMas[i] = new Connection();
print("передан " + i + "-ый обьект в массиве с весом:" + connectionMas[i].weight);
return connectionMas[i++];
} else {
print("массив закончился!");
return null;
}
}
}
class Connection {
int weight = 0;
Connection() {
Random rand = new Random(System.nanoTime());// currentTimeMillis()
this.weight = rand.nextInt(1000);
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
public class Test {
public static void main(String args[]) {
Connection[] tempMas = new Connection[5];
for (int i = 0; i < tempMas.length; i++)
tempMas[i] = ConectionManager.giveMeConnection();
}
public static void print(Object obj) {
System.out.println(obj);
}
public static void print() {
System.out.println();
}
public static void printnb(Object obj) {
System.out.print(obj);
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
import static testProject.Test.*;
class Test2 {
private String line;
Test2() {
print("Test2");
line = "Constructed";
}
public String toString() {
return line;
}
}
class Test3 {
private String line1, line2 = "2-я строка", line3 = "3-я строка", line4; // нициализация в точке определения
private int i;
private float toy;
Test2 castille;
Test3() {
line1 = "1-ая строка"; // инициализация в конструкторе
toy = 10517f;
castille = new Test2();
}
{ // инициализация экземпляра
i = 99;
}
public String toString() {
if (line4 == null) // отложенная нициализация
line4 = "4-я строка";
return "line1 = " + line1 + " line2 = " + line2 + " line3 = " + line3 + " line4 = " + "\ni = " + i + " toy = "
+ toy + " castille " + castille;
}
}
public static void main(String args[]) {
Test3 testObj = new Test3();
print(testObj);
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
class Test4 {
public String toString() {
Test testObj = new Test();
testObj.f = 14142f;
testObj.i = 990;
testObj.line = "line";
return "f = " + testObj.f + " i = " + testObj.i + " line = " + testObj.line + " testObj = " + testObj;
}
}
package testProject;
public class Test {
String line;
int i;
float f;
public static void main(String args[]) {
print(new Test4());
}
public String toString() {
return "pidr";
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
package testProject;
public class Test {
private String a = " Test ";