From 33093c7399e5dfd85ef672271c487dfdc152021c Mon Sep 17 00:00:00 2001 From: htom Date: Tue, 28 Oct 2025 09:17:23 +0100 Subject: [PATCH] ora5, formatter implementalasa elearning todo --- ora5/proj1/untitled/.gitignore | 30 +++++++ ora5/proj1/untitled/.idea/.gitignore | 3 + ora5/proj1/untitled/.idea/misc.xml | 6 ++ ora5/proj1/untitled/.idea/modules.xml | 8 ++ ora5/proj1/untitled/.idea/vcs.xml | 6 ++ ora5/proj1/untitled/Building.iml | 11 +++ .../src/hu/unideb/inf/ps/Building.java | 45 ++++++++++ .../hu/unideb/inf/ps/BuildingComparator.java | 10 +++ .../untitled/src/hu/unideb/inf/ps/Room.java | 53 ++++++++++++ .../untitled/src/hu/unideb/inf/ps/Runner.java | 81 +++++++++++++++++ ora5/proj2/Map/.gitignore | 30 +++++++ ora5/proj2/Map/.idea/.gitignore | 3 + ora5/proj2/Map/.idea/misc.xml | 6 ++ ora5/proj2/Map/.idea/modules.xml | 8 ++ ora5/proj2/Map/.idea/vcs.xml | 6 ++ ora5/proj2/Map/Map.iml | 11 +++ .../Map/src/hu/unideb/inf/ps/Building.java | 45 ++++++++++ ora5/proj2/Map/src/hu/unideb/inf/ps/Room.java | 53 ++++++++++++ .../Map/src/hu/unideb/inf/ps/Runner.java | 86 +++++++++++++++++++ 19 files changed, 501 insertions(+) create mode 100644 ora5/proj1/untitled/.gitignore create mode 100644 ora5/proj1/untitled/.idea/.gitignore create mode 100644 ora5/proj1/untitled/.idea/misc.xml create mode 100644 ora5/proj1/untitled/.idea/modules.xml create mode 100644 ora5/proj1/untitled/.idea/vcs.xml create mode 100644 ora5/proj1/untitled/Building.iml create mode 100644 ora5/proj1/untitled/src/hu/unideb/inf/ps/Building.java create mode 100644 ora5/proj1/untitled/src/hu/unideb/inf/ps/BuildingComparator.java create mode 100644 ora5/proj1/untitled/src/hu/unideb/inf/ps/Room.java create mode 100644 ora5/proj1/untitled/src/hu/unideb/inf/ps/Runner.java create mode 100644 ora5/proj2/Map/.gitignore create mode 100644 ora5/proj2/Map/.idea/.gitignore create mode 100644 ora5/proj2/Map/.idea/misc.xml create mode 100644 ora5/proj2/Map/.idea/modules.xml create mode 100644 ora5/proj2/Map/.idea/vcs.xml create mode 100644 ora5/proj2/Map/Map.iml create mode 100644 ora5/proj2/Map/src/hu/unideb/inf/ps/Building.java create mode 100644 ora5/proj2/Map/src/hu/unideb/inf/ps/Room.java create mode 100644 ora5/proj2/Map/src/hu/unideb/inf/ps/Runner.java diff --git a/ora5/proj1/untitled/.gitignore b/ora5/proj1/untitled/.gitignore new file mode 100644 index 0000000..13275f1 --- /dev/null +++ b/ora5/proj1/untitled/.gitignore @@ -0,0 +1,30 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ +.kotlin + +### 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 \ No newline at end of file diff --git a/ora5/proj1/untitled/.idea/.gitignore b/ora5/proj1/untitled/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/ora5/proj1/untitled/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/ora5/proj1/untitled/.idea/misc.xml b/ora5/proj1/untitled/.idea/misc.xml new file mode 100644 index 0000000..188022c --- /dev/null +++ b/ora5/proj1/untitled/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora5/proj1/untitled/.idea/modules.xml b/ora5/proj1/untitled/.idea/modules.xml new file mode 100644 index 0000000..d335bac --- /dev/null +++ b/ora5/proj1/untitled/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ora5/proj1/untitled/.idea/vcs.xml b/ora5/proj1/untitled/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/ora5/proj1/untitled/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora5/proj1/untitled/Building.iml b/ora5/proj1/untitled/Building.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/ora5/proj1/untitled/Building.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ora5/proj1/untitled/src/hu/unideb/inf/ps/Building.java b/ora5/proj1/untitled/src/hu/unideb/inf/ps/Building.java new file mode 100644 index 0000000..8248ac4 --- /dev/null +++ b/ora5/proj1/untitled/src/hu/unideb/inf/ps/Building.java @@ -0,0 +1,45 @@ +package hu.unideb.inf.ps; + +import java.util.Objects; + +public class Building implements Comparable{ + private String name; + private String address; + + public Building(String name, String address) { + this.name = name; + this.address = address; + } + + public String getName() { + return name; + } + + public String getAddress() { + return address; + } + + @Override + public String toString() { + return "Building{" + + "name='" + name + '\'' + + ", address='" + address + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Building building)) return false; + return Objects.equals(name, building.name) && Objects.equals(address, building.address); + } + + @Override + public int hashCode(){ + return Objects.hashCode(name); + } + + @Override + public int compareTo(Building building) { + return this.name.compareTo(building.name); + } +} diff --git a/ora5/proj1/untitled/src/hu/unideb/inf/ps/BuildingComparator.java b/ora5/proj1/untitled/src/hu/unideb/inf/ps/BuildingComparator.java new file mode 100644 index 0000000..3932a5e --- /dev/null +++ b/ora5/proj1/untitled/src/hu/unideb/inf/ps/BuildingComparator.java @@ -0,0 +1,10 @@ +package hu.unideb.inf.ps; + +import java.util.Comparator; + +public class BuildingComparator implements Comparator { + @Override + public int compare(Building o1, Building o2) { + return o1.getName().compareTo(o2.getName()); + } +} diff --git a/ora5/proj1/untitled/src/hu/unideb/inf/ps/Room.java b/ora5/proj1/untitled/src/hu/unideb/inf/ps/Room.java new file mode 100644 index 0000000..4e6ccb7 --- /dev/null +++ b/ora5/proj1/untitled/src/hu/unideb/inf/ps/Room.java @@ -0,0 +1,53 @@ +package hu.unideb.inf.ps; + +import java.util.ArrayList; + +public class Room { + private Building building; + private String roomId; + private int numberOfSeats; + private ArrayList attributes = new ArrayList(); + + public Room(String roomId, Building building) { + this.roomId = roomId; + this.building = building; + } + + public void setNumberOfSeats(int numberOfSeats) { + this.numberOfSeats = numberOfSeats; + } + + public void addAttribute(String attribute){ + this.attributes.add(attribute); + } + + public void delAttribute(String attribute){ + this.attributes.remove(attribute); + } + + public Building getBuilding() { + return building; + } + + public String getRoomId() { + return roomId; + } + + public int getNumberOfSeats() { + return numberOfSeats; + } + + public ArrayList getAttributes() { + return attributes; + } + + @Override + public String toString() { + return "Room{" + + "building=" + building + + ", roomId='" + roomId + '\'' + + ", numberOfSeats=" + numberOfSeats + + ", attributes=" + attributes + + '}'; + } +} diff --git a/ora5/proj1/untitled/src/hu/unideb/inf/ps/Runner.java b/ora5/proj1/untitled/src/hu/unideb/inf/ps/Runner.java new file mode 100644 index 0000000..873ff9a --- /dev/null +++ b/ora5/proj1/untitled/src/hu/unideb/inf/ps/Runner.java @@ -0,0 +1,81 @@ +package hu.unideb.inf.ps; + +import java.util.Comparator; +import java.util.HashSet; +import java.util.TreeSet; + +public class Runner { + static void main() { + //Set epitese + HashSet hsb1 = new HashSet();//egy elem egyszer de meg kell mondani mitol lesz egyedi + hsb1.add(new Building("teokj", "kassai ut 26")); + hsb1.add(new Building("teokj", "kassai ut 26")); + hsb1.add(new Building("ik", "kassai ut 26")); + hsb1.add(new Building("ik", "kassai ut 26")); + + System.out.println(hsb1); + + for(Building b : hsb1){ + System.out.println(b); + } + + System.out.println("\nTreeSet"); + TreeSet tsb1 = new TreeSet<>(); + tsb1.add(new Building("teokj", "kassai ut 26")); + tsb1.add(new Building("ik", "kassai ut 26")); + tsb1.add(new Building("teokj", "kassai ut 26")); + tsb1.add(new Building("ik", "kassai ut 26")); + + for(Building b: tsb1){ + System.out.println(b); + } + + System.out.println("\ntsb2"); + TreeSet tsb2 = new TreeSet<>(new Comparator() { + @Override + public int compare(Building building, Building t1) { + int s = t1.getName().compareTo(building.getName()); + if (s != 0) return s; + return t1.getAddress().compareTo(building.getAddress()); + } + }); + + tsb2.add(new Building("teokj", "kassai ut 26")); + tsb2.add(new Building("ik", "kassai ut 26")); + tsb2.add(new Building("teokj", "kassai ut 26")); + tsb2.add(new Building("ik", "kassai ut 26")); + tsb2.add(new Building("foepulet", "egyetem ter")); + + for(Building b: tsb2){ + System.out.println(b); + } + + System.out.println("\ntsb2"); + TreeSet tsb3 = new TreeSet<>((Building building, Building t1) -> { + int s = t1.getName().compareTo(building.getName()); + if (s != 0) return s; + return t1.getAddress().compareTo(building.getAddress()); + }); + + tsb3.add(new Building("teokj", "kassai ut 26")); + tsb3.add(new Building("ik", "kassai ut 26")); + tsb3.add(new Building("teokj", "kassai ut 26")); + tsb3.add(new Building("ik", "kassai ut 26")); + tsb3.add(new Building("foepulet", "egyetem ter")); + + for(Building b: tsb3){ + System.out.println(b); + } + + TreeSet tsb4 = new TreeSet<>(new BuildingComparator()); + tsb4.add(new Building("teokj", "kassai ut 26")); + tsb4.add(new Building("ik", "kassai ut 26")); + tsb4.add(new Building("teokj", "kassai ut 26")); + tsb4.add(new Building("ik", "kassai ut 26")); + tsb4.add(new Building("foepulet", "egyetem ter")); + + for(Building b: tsb4){ + System.out.println(b); + } + } +} diff --git a/ora5/proj2/Map/.gitignore b/ora5/proj2/Map/.gitignore new file mode 100644 index 0000000..13275f1 --- /dev/null +++ b/ora5/proj2/Map/.gitignore @@ -0,0 +1,30 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ +.kotlin + +### 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 \ No newline at end of file diff --git a/ora5/proj2/Map/.idea/.gitignore b/ora5/proj2/Map/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/ora5/proj2/Map/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/ora5/proj2/Map/.idea/misc.xml b/ora5/proj2/Map/.idea/misc.xml new file mode 100644 index 0000000..188022c --- /dev/null +++ b/ora5/proj2/Map/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora5/proj2/Map/.idea/modules.xml b/ora5/proj2/Map/.idea/modules.xml new file mode 100644 index 0000000..1de538f --- /dev/null +++ b/ora5/proj2/Map/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ora5/proj2/Map/.idea/vcs.xml b/ora5/proj2/Map/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/ora5/proj2/Map/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora5/proj2/Map/Map.iml b/ora5/proj2/Map/Map.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/ora5/proj2/Map/Map.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ora5/proj2/Map/src/hu/unideb/inf/ps/Building.java b/ora5/proj2/Map/src/hu/unideb/inf/ps/Building.java new file mode 100644 index 0000000..d2ee0a3 --- /dev/null +++ b/ora5/proj2/Map/src/hu/unideb/inf/ps/Building.java @@ -0,0 +1,45 @@ +package hu.unideb.inf.ps; + +import java.util.Objects; + +public class Building implements Comparable{ + private String name; + private String address; + + public Building(String name, String address) { + this.name = name; + this.address = address; + } + + public String getName() { + return name; + } + + public String getAddress() { + return address; + } + + @Override + public String toString() { + return "Building{" + + "name='" + name + '\'' + + ", address='" + address + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Building building)) return false; + return Objects.equals(name, building.name) && Objects.equals(address, building.address); + } + + @Override + public int hashCode(){ + return Objects.hashCode(name); + } + + @Override + public int compareTo(Building building) { + return building.name.compareTo(this.name); + } +} diff --git a/ora5/proj2/Map/src/hu/unideb/inf/ps/Room.java b/ora5/proj2/Map/src/hu/unideb/inf/ps/Room.java new file mode 100644 index 0000000..2bfd7b7 --- /dev/null +++ b/ora5/proj2/Map/src/hu/unideb/inf/ps/Room.java @@ -0,0 +1,53 @@ +package hu.unideb.inf.ps; + +import java.util.ArrayList; + +public class Room { + private Building building; + private String roomId; + private int numberOfSeats; + private ArrayList attributes = new ArrayList(); + + public Room(Building building,String roomId) { + this.roomId = roomId; + this.building = building; + } + + public void setNumberOfSeats(int numberOfSeats) { + this.numberOfSeats = numberOfSeats; + } + + public void addAttribute(String attribute){ + this.attributes.add(attribute); + } + + public void delAttribute(String attribute){ + this.attributes.remove(attribute); + } + + public Building getBuilding() { + return building; + } + + public String getRoomId() { + return roomId; + } + + public int getNumberOfSeats() { + return numberOfSeats; + } + + public ArrayList getAttributes() { + return attributes; + } + + @Override + public String toString() { + return "Room{" + + "building=" + building + + ", roomId='" + roomId + '\'' + + ", numberOfSeats=" + numberOfSeats + + ", attributes=" + attributes + + '}'; + } +} diff --git a/ora5/proj2/Map/src/hu/unideb/inf/ps/Runner.java b/ora5/proj2/Map/src/hu/unideb/inf/ps/Runner.java new file mode 100644 index 0000000..64e0d67 --- /dev/null +++ b/ora5/proj2/Map/src/hu/unideb/inf/ps/Runner.java @@ -0,0 +1,86 @@ +package hu.unideb.inf.ps; + +import java.util.*; + +public class Runner { + static void main() { + ArrayList rooms = new ArrayList<>(); + rooms.add(new Room(new Building("deik", "kassai 26"), "f0")); + rooms.add(new Room(new Building("deik", "kassai 28"), "f0")); + rooms.add(new Room(new Building("teokj", "kassai 27"), "f1")); + rooms.add(new Room(new Building("teokj", "kassai 27"), "f2")); + rooms.add(new Room(new Building("teokj", "kassai 28"), "f3")); + rooms.add(new Room(new Building("deik", "kassai 26"), "f5")); + rooms.add(new Room(new Building("kemia", "egyetem ter 1"), "k2")); + + for(Room room: rooms){ + System.out.println(room); + } + + System.out.println("\nHasmap 1"); + HashMap> hm1 = new HashMap<>(); + for (Room room: rooms){ + ArrayList v; + Building key = room.getBuilding(); + if (hm1.containsKey(key)){ + v = hm1.get(key); + }else{ + v = new ArrayList<>(); + } + v.add(room); + + hm1.put(room.getBuilding(), v); + } + + for (Building building : hm1.keySet()) { + System.out.println(building); + System.out.println(hm1.get(building)); + } + + System.out.println("\ntree map 1"); + TreeMap> tm1 = new TreeMap<>(); + for (Room room : rooms) { + ArrayList v; + if(tm1.containsKey(room.getBuilding())){ + v = tm1.get(room.getBuilding()); + }else{ + v = new ArrayList<>(); + } + + v.add(room); + tm1.put(room.getBuilding(), v); + } + + for (Map.Entry> buildingArrayListEntry : tm1.entrySet()) { + System.out.println(buildingArrayListEntry.getKey()); + System.out.println(buildingArrayListEntry.getValue()); + } + + System.out.println("\ntree map 2 comparator constructor"); + TreeMap> tm2 = new TreeMap<>(new Comparator() { + @Override + public int compare(Building o1, Building o2) { + int s= o2.getName().compareTo(o1.getName()); + if (s != 0) return s; + return o2.getAddress().compareTo(o1.getAddress()); + } + }); + + for (Room room : rooms) { + ArrayList v; + if(tm2.containsKey(room.getBuilding())){ + v = tm2.get(room.getBuilding()); + }else{ + v = new ArrayList<>(); + } + + v.add(room); + tm2.put(room.getBuilding(), v); + } + + for (Building building : tm2.keySet()) { + System.out.println(building); + System.out.println(tm2.get(building)); + } + } +}