Skip to content

Commit

Permalink
Изменения на занятии 1
Browse files Browse the repository at this point in the history
  • Loading branch information
stden committed Jan 16, 2016
1 parent 4c7f3e3 commit 9d0a7af
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 59 deletions.
24 changes: 12 additions & 12 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions .idea/deployment.xml

This file was deleted.

1 change: 1 addition & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
public class HelloWorldRussian {
public static void main(String[] args) {
System.out.println("Здравствуй, Мир!");
int мояПеременная = 10;
int moyaPeremennya = 111;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public static void main(String[] args) {
for (int j = 0; j < 10; j++) {
System.out.println("j = " + j);
}
for (int j = 0; j < 10; j++) {
for (int k = 0; k < 10; k++) {
System.out.println(i * j);
}
}
}
//<--
}
23 changes: 16 additions & 7 deletions 01_HelloWorld/src/main/java/p01_datatypes/A_PrimitiveTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public static void main(String args[]) {

// **Целочисленные типы:**
// 1. 8 битное целое - **byte**: -128..127.
// Подробнее: http://ru.wikipedia.org/wiki/Дополнительный_код_(представление_числа)
// Подробнее:
// http://ru.wikipedia.org/wiki/Дополнительный_код_(представление_числа)
byte varWithoutValue;
varWithoutValue = 3; // Значение присваиваем позже
varWithoutValue = (byte) (varWithoutValue + 255);
Expand Down Expand Up @@ -42,7 +43,8 @@ public static void main(String args[]) {
// 2. 16-битное целое **short**: -2^15..2^15-1 -32768..32767
//-->
short sh = 32767; // -32768..32767
System.out.println("short = " + sh + " " + Short.MIN_VALUE + ".." + Short.MAX_VALUE);
System.out.println("short = " + sh + " " +
Short.MIN_VALUE + ".." + Short.MAX_VALUE);
//<--

// 3. 32-битное целое **int**
Expand All @@ -51,12 +53,16 @@ public static void main(String args[]) {
System.out.println("Integer.toBinaryString(integerBinary) = " + Integer.toBinaryString(integerBinary));
// Java6
int intBin = Integer.parseInt("1011", 2);
System.out.println("intBin = " + Integer.toBinaryString(intBin));
System.out.println("intBin = " +
Integer.toBinaryString(intBin));
int integerHex = 0xFFA9; // Шестнадцатеричная система счисления
System.out.printf("Hex: %X %n", integerHex); // FFA9
System.out.printf("Hex: %x %n", integerHex); // ffa9
System.out.printf("Hex: %04X %n", integerHex);
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
int maxInt = 2147483647; // 2^31-1
System.out.printf("maxInt = %08X %n", maxInt);
System.out.println("Integer.MAX_VALUE = " + Integer.MAX_VALUE);
//<--

// 4. 64-битное целое **long**
Expand Down Expand Up @@ -92,7 +98,9 @@ public static void main(String args[]) {

// Вещественные типы (действительные)
// 5. **float** - 4 байта
float floatValue = 1.0f;
float floatValue = 2.3f;
System.out.printf("floatValue = %f%n", floatValue);
floatValue = 1.0f;
System.out.printf("floatValue = %f%n", floatValue);
System.out.println("Float.MIN_VALUE = " + Float.MIN_VALUE);
System.out.println("Float.MAX_VALUE = " + Float.MAX_VALUE);
Expand All @@ -108,6 +116,7 @@ public static void main(String args[]) {
boolean bool = random.nextBoolean();
boolean bool2 = random.nextBoolean();
boolean bool3 = bool && bool2;
// && - И || - ИЛИ
System.out.printf("bool3 = %s%n", bool3);

//
Expand All @@ -119,9 +128,10 @@ public static void main(String args[]) {
// Boolean

// 8. Символьный тип **char**
char c1 = 'П', c2 = 'Р', c3 = 'И', c4 = 'В', c5 = 'Е', c6 = 'Т';
char c1 = 'П', c2 = 'Р', c3 = 'И',
c4 = 'В', c5 = 'Е', c6 = 'Т';
System.out.println(c1 + c2 + c3 + c4 + c5 + c6);
// Character
Character сClass = c1;

//
// Переменные, методы, классы можно
Expand Down Expand Up @@ -190,7 +200,6 @@ public static void main(String args[]) {
a = 2;
int aa = a++ + a++; // aa = 4
System.out.println("aa = " + aa);
// a = 3
int a1 = ++a;
System.out.println("a1 = " + a1);
++a; // Префиксная форма
Expand Down
8 changes: 6 additions & 2 deletions 01_HelloWorld/src/main/java/p01_datatypes/D_Arrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ public static void main(String[] args) {

// Сокращённая форма инициализации
int[] intArray2 = {1, 2, 3, 10};
// Массив
int[] intArray3 = new int[100];
//<--

// Пробегаем по всем элементам массива
//-->
for (int i = 0; i < intArray2.length; i++) {
System.out.println("intArray2[" + i + "] = " + intArray1[i]);
System.out.println("intArray1[" + i + "] = " +
intArray1[i]);
}
// Если нам не важны индексы, то мы можем использовать цикл "foreach"
// Если нам не важны индексы,
// то мы можем использовать цикл "foreach"
for (int i : intArray1) {
System.out.print(i + " ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void method1(int i) {
// i передаётся по ссылке
//-->
static void myMethod2(MyClass i) {
//i = new MyClass();
// i = new MyClass();
i.i += 20;
assertEquals("myMethod2: ", 30, i.i);
}
Expand Down
20 changes: 11 additions & 9 deletions 02_OOP/src/main/java/encapsula/Square.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@
public interface Square {

/**
* Изменяем длину стороны
* @param value новая длина
* @return длина стороны
*/
void setSide(double value);
double getSide();

/**
* Изменяем площадь квадрата
* Изменяем длину стороны
*
* @param value новая длина
*/
void setArea(double value);
void setSide(double value);

/**
* @return длина стороны
* @return получаем площадь
*/
double getSide();
double getArea();

/**
* @return получаем площадь
* Изменяем площадь квадрата
*
* @param value новая длина
*/
double getArea();
void setArea(double value);
}
2 changes: 1 addition & 1 deletion 02_OOP/src/main/java/inheritance/SubClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class SubClass extends SuperClass {

public SubClass() {
//super(); // Вызываем конструктор суперкласса
System.out.println("Подкласс");
System.out.println("Конструктор Подкласса");
}

public static void main(String[] args) {
Expand Down
14 changes: 9 additions & 5 deletions 02_OOP/src/test/java/SquareTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ public class SquareTest {
@Test
public void testSideArea() {
Square square = new SquareSide();
testSquare(new SquareSide());
testSquare(square);
testSquare(new SquareArea());
}

private void testSquare(Square square) {
square.setSide(10);
System.out.println("square.getSide() = " + square.getSide());
System.out.println("square.getArea() = " + square.getArea());
System.out.println("square.getSide() = " +
square.getSide());
System.out.println("square.getArea() = " +
square.getArea());
assertEquals(10.0, square.getSide(), 1e-16);
assertEquals(100.0, square.getArea(), 1e-16);

square.setArea(144);
System.out.println("square.getSide() = " + square.getSide());
System.out.println("square.getArea() = " + square.getArea());
System.out.println("square.getSide() = " +
square.getSide());
System.out.println("square.getArea() = " +
square.getArea());
assertEquals(12.0, square.getSide(), 1e-16);
assertEquals(144.0, square.getArea(), 1e-16);
}
Expand Down
2 changes: 1 addition & 1 deletion homework.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Домашнее задание
Домашнее задание
-----------------

Подумать о проекте, о предметной области
Expand Down
Binary file modified java.ppt
Binary file not shown.

0 comments on commit 9d0a7af

Please sign in to comment.