lab2
tisit 3 weeks ago
commit 7b631ed852

BIN
._.git

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
._out

Binary file not shown.

BIN
._src

Binary file not shown.

Binary file not shown.

29
.gitignore vendored

@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="homebrew-23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/lab2.iml" filepath="$PROJECT_DIR$/lab2.iml" />
</modules>
</component>
</project>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

Binary file not shown.

@ -0,0 +1,5 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

@ -0,0 +1,31 @@
public class MyDate {
private int day, month, year;
public MyDate(int day, int month, int year) {
this.day = day;
this.month = month;
this.year = year;
}
@Override
public boolean equals(Object o) {
// Если ссылки равны объекты идентичны
if (this == o) return true;
// Если объект null или классы не совпадают возвращаем false
if (o == null || getClass() != o.getClass()) return false;
// Явное приведение типа и сравнение полей
MyDate myDate = (MyDate) o;
return day == myDate.day &&
month == myDate.month &&
year == myDate.year;
}
@Override
public int hashCode() {
// Формирование хэш-кода
int result = day;
result = 31 * result + month;
result = 31 * result + year;
return result;
}
}

@ -0,0 +1,24 @@
public class TestEquals {
public static void main(String[] args) {
MyDate date1 = new MyDate(7, 11, 2014);
MyDate date2 = new MyDate(7, 11, 2014);
if (date1 == date2)
System.out.println("date1 is identical to date2");
else
System.out.println("date1 is not identical to date2");
if (date1.equals(date2))
System.out.println("date1 equals date2");
else
System.out.println("date1 does not equal date2");
System.out.println("set date2 = date1");
date2 = date1;
if (date1 == date2)
System.out.println("date1 is identical to date2");
else
System.out.println("date1 is not identical to date2");
}
}

Binary file not shown.
Loading…
Cancel
Save