-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d4a9f9
commit 0a89444
Showing
8 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
materials/2024-2025/11b/2024-11-04-object-class/.gitignore
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
3 changes: 3 additions & 0 deletions
3
materials/2024-2025/11b/2024-11-04-object-class/.idea/.gitignore
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
materials/2024-2025/11b/2024-11-04-object-class/.idea/misc.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
materials/2024-2025/11b/2024-11-04-object-class/.idea/modules.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
materials/2024-2025/11b/2024-11-04-object-class/.idea/vcs.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
materials/2024-2025/11b/2024-11-04-object-class/2024-11-04-object-class.iml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
44 changes: 44 additions & 0 deletions
44
materials/2024-2025/11b/2024-11-04-object-class/src/Main.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
Object o1 = new Object(); | ||
Object o2 = new Object(); | ||
|
||
System.out.println(o1); | ||
System.out.println(o2); | ||
System.out.println(o1 == o2); | ||
System.out.println(o1.equals(o2)); | ||
System.out.println(o1.toString()); | ||
|
||
Pastry p1 = new Pastry("Prava", false); | ||
Pastry p2 = new Pastry("Sofiiska", true); | ||
Pastry p3 = new Pastry("Prava", false); | ||
|
||
System.out.println(p1); | ||
System.out.println(p2); | ||
System.out.println(p1 == p2); | ||
System.out.println(p1.equals(p2)); | ||
System.out.println(p1.hashCode()); | ||
System.out.println(p2.hashCode()); | ||
|
||
System.out.println(p1 == p3); | ||
System.out.println(p1.equals(p3)); | ||
|
||
Map<Pastry, Pastry> map1 = new HashMap<>(); | ||
map1.put(p1, p1); | ||
map1.put(p2, p2); | ||
map1.put(p3, p3); | ||
System.out.println(map1); | ||
System.out.println(map1.keySet()); | ||
|
||
Map<Pastry, Pastry> map2 = new TreeMap<>(); | ||
map2.put(p1, p1); | ||
map2.put(p2, p2); | ||
map2.put(p3, p3); | ||
System.out.println(map2); | ||
System.out.println(map2.keySet()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
materials/2024-2025/11b/2024-11-04-object-class/src/Pastry.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import java.util.Objects; | ||
|
||
public class Pastry { | ||
private String name; | ||
private boolean hasCheese; | ||
|
||
public Pastry(String name, boolean hasCheese) { | ||
this.name = name; | ||
this.hasCheese = hasCheese; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public boolean getHasCheese() { | ||
return hasCheese; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Pastry{" + | ||
"name='" + name + '\'' + | ||
", hasCheese=" + hasCheese + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Pastry pastry = (Pastry) o; | ||
return hasCheese == pastry.hasCheese && | ||
// Objects.equals(name, pastry.name); | ||
name.equals(pastry.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, hasCheese); | ||
} | ||
} |