This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Address { | |
| private String street; | |
| private String city; | |
| private String country; | |
| private String zipCode; | |
| public Address(String street, String city, String country) { | |
| this.street = street; | |
| this.city = city; | |
| this.country = country; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package junitex.ex1; | |
| //Unit-test1: Юнит-тестирование в Java. Как бы мы тестировали программу без юнит-тестов? | |
| //The GOAL IS the possibility to check every class and every method in order to convince/assure that every works correctly/properly. | |
| // Главная цель -иметь возможность проверить каждый класс и каждый метод чтобы убедиться что все работает правильно, перед тем как мы вносим свои изменения в код(для расширения проекта например) | |
| // Unit-testing позволяет разрабатывать его отдельно, не загромаждая продакшн код, и *продать* "чистый" от тестов код. | |
| public class Cat { | |
| String name; | |
| int age; // В продакшене ДЕЛАТЬ поля класса private и использовать getters&setters | |
| int hungry; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package homeWorkTicTacToe; | |
| public class Computer { | |
| public Point getShootPoint() { | |
| return Point.getRandomPoint(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ioClassWork2Serialization; | |
| import java.io.Serializable; | |
| public class Cat implements Serializable { | |
| private static final long serialVersionUID = 4003956952389021871L; //С помощью serialVersionUID избегаем java.io.InvalidClassException, т.к | |
| //Без явного определения serialVersionUID, он генерируется автоматическии при любых ИЗМЕНЕНИЯХ класса(ТИПА и КОЛ-ВА ПЕРЕМЕННЫХ класса), | |
| //поэтому любые изменения класса между записью и чтением приведут к java.io.InvalidClassException, | |
| //во избежании этого, указываем в классе ЯВНО(с помошью idea) - serialVersionUID == ВЕРСИЮ КЛАССА. | |
| private String name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ioClassWork; | |
| import java.io.*; | |
| public class Main5DataOutputStream { | |
| public static void main(String[] args) {//todo DONE: TRY-WITH-RESOURCES | |
| String dataFile = "to.txt"; | |
| //DataOutputStream out;//класс который поможет записать в файл в пермешку: целые числа, дробные числа, и строчки-даже в формате UTF. | |
| //Это НЕ символьный поток,а байтовый-он будет хранить в определенном формате самые разные типы данных, поэтому наследует от абстр.-OutputStream. | |
| //А для символьныех потоков используем InputStreamReader -> Reader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package homeWorkAnonymousClass; | |
| public interface FutureCallback { | |
| void completed(); | |
| void failed(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package homeWorkATM; | |
| public class ATM { | |
| private CreditCard currentCard; | |
| void insertCard(CreditCard card){ | |
| // Избежать повторной вставки //Avoid second insert | |
| if (currentCard == null) { | |
| currentCard = card; | |
| System.out.println("The card inserted."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package java0.lesson8.homework82.wide.library; | |
| public class Book extends Thing { | |
| private int ISBN = 1000; | |
| private String bookName; | |
| private String bookAuthor; | |
| private int publishingYear; | |
| public Book(String kind, int borrowPrice, Helper helper, int ISBN, String bookName, String bookAuthor, int publishingYear) { | |
| super(kind, borrowPrice, helper); | |
| this.ISBN = ISBN; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package catBowlNonStatic; | |
| public class Bowl { | |
| double foodAmount = 100; | |
| double foodConsume = 0.2; | |
| double wholeFoodConsume; | |
| void feedCat(Cat cat){ | |
| if (cat.age <= 3) { | |
| wholeFoodConsume = 4*foodConsume; | |
| foodAmount = foodAmount - wholeFoodConsume; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package catBowlNonStatic; | |
| public class Bowl { | |
| double foodAmount = 100; | |
| double foodConsume = 0.2; | |
| double wholeFoodConsume; | |
| void feedCat(Cat cat){ | |
| if (cat.age <= 3) { | |
| wholeFoodConsume = 4*foodConsume; |
NewerOlder