diff --git a/ora3/iproj1/untitled/.idea/misc.xml b/ora3/iproj1/untitled/.idea/misc.xml index 89ee753..428d324 100644 --- a/ora3/iproj1/untitled/.idea/misc.xml +++ b/ora3/iproj1/untitled/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/ora4/proj1/untitled/.gitignore b/ora4/proj1/untitled/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/ora4/proj1/untitled/.gitignore @@ -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 \ No newline at end of file diff --git a/ora4/proj1/untitled/.idea/.gitignore b/ora4/proj1/untitled/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/ora4/proj1/untitled/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/ora4/proj1/untitled/.idea/misc.xml b/ora4/proj1/untitled/.idea/misc.xml new file mode 100644 index 0000000..428d324 --- /dev/null +++ b/ora4/proj1/untitled/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora4/proj1/untitled/.idea/modules.xml b/ora4/proj1/untitled/.idea/modules.xml new file mode 100644 index 0000000..3007dae --- /dev/null +++ b/ora4/proj1/untitled/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ora4/proj1/untitled/.idea/vcs.xml b/ora4/proj1/untitled/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/ora4/proj1/untitled/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora4/proj1/untitled/src/Runner.java b/ora4/proj1/untitled/src/Runner.java new file mode 100644 index 0000000..b85e750 --- /dev/null +++ b/ora4/proj1/untitled/src/Runner.java @@ -0,0 +1,33 @@ +import hu.unideb.inf.pv.Bicycle; +import hu.unideb.inf.pv.Car; +import hu.unideb.inf.pv.Vehicle; + +public class Runner { + public static void main(String[] args) { + Vehicle v1 = new Vehicle("ABC-123"); + System.out.println("v1"+v1); + + Vehicle v2 = new Vehicle("QWE-321", 2); + System.out.println("v2"+v2); + v2.setMove(); + System.out.println("v2.move: " + v2); + + Car c1 = new Car("WER-456"); + Car c2 = new Car("TZU-654", 200); + System.out.println("c1" + c1 + ", c2" + c2); + + Bicycle b1 = new Bicycle("UIO-789"); + + Vehicle[] vehicles = new Vehicle[5]; + vehicles[0] = v1; + vehicles[1] = v2; + vehicles[2] = c1; + vehicles[3] = c2; + vehicles[4] = new Vehicle("LKJ-246"); + + for (Vehicle vehicle : vehicles) { + System.out.println(vehicle); + } + + } +} \ No newline at end of file diff --git a/ora4/proj1/untitled/src/hu/unideb/inf/pv/Bicycle.java b/ora4/proj1/untitled/src/hu/unideb/inf/pv/Bicycle.java new file mode 100644 index 0000000..b2ca1a6 --- /dev/null +++ b/ora4/proj1/untitled/src/hu/unideb/inf/pv/Bicycle.java @@ -0,0 +1,26 @@ +package hu.unideb.inf.pv; + +public class Bicycle extends Vehicle{ + private int size; + + public Bicycle(String registationNumber) { + super(registationNumber, 2); + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Bicycle{"); + sb.append(super.toString()); + sb.append("size=").append(size); + sb.append('}'); + return sb.toString(); + } +} diff --git a/ora4/proj1/untitled/src/hu/unideb/inf/pv/Car.java b/ora4/proj1/untitled/src/hu/unideb/inf/pv/Car.java new file mode 100644 index 0000000..173f10e --- /dev/null +++ b/ora4/proj1/untitled/src/hu/unideb/inf/pv/Car.java @@ -0,0 +1,64 @@ +package hu.unideb.inf.pv; + +public class Car extends Vehicle{ + private boolean engineIsWorking; + private int horsePower; + + public Car(String licensePlateNumber) { + super(licensePlateNumber, 4); + engineIsWorking = false; + } + + public Car(String licensePlateNumber, int horsePower){ + this(licensePlateNumber); + this.horsePower = horsePower; + } + + public int getHorsePower() { + return horsePower; + } + + public void setHorsePower(int horsePower) { + this.horsePower = horsePower; + } + + public boolean isEngineIsWorking() { + return engineIsWorking; + } + + public void setEngineToWorking() { + this.engineIsWorking = true; + } + + public void setEngineToStop(){ + this.engineIsWorking = false; + } + + @Override + public void setMove() { + super.setMove(); + this.setEngineToWorking(); + } + + @Override + public void setPark() { + super.setPark(); + this.setEngineToStop(); + } + + @Override + public void setStop() { + super.setStop(); + this.setEngineToStop(); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Car{"); + sb.append(super.toString()); + sb.append("engineIsWorking=").append(engineIsWorking); + sb.append(", horsePower=").append(horsePower); + sb.append('}'); + return sb.toString(); + } +} diff --git a/ora4/proj1/untitled/src/hu/unideb/inf/pv/Vehicle.java b/ora4/proj1/untitled/src/hu/unideb/inf/pv/Vehicle.java new file mode 100644 index 0000000..280dde3 --- /dev/null +++ b/ora4/proj1/untitled/src/hu/unideb/inf/pv/Vehicle.java @@ -0,0 +1,64 @@ +package hu.unideb.inf.pv; + +import java.util.Objects; + +public class Vehicle { + private VehicleStatus status; + private int NumberOfWheels; + private String id; + + public Vehicle(String id){ + this.id = id; + status = VehicleStatus.PARK; + } + + public Vehicle(String id, int NumberOfWheels){ + this(id); + this.NumberOfWheels = NumberOfWheels; + } + + public void setMove() { + this.status = VehicleStatus.MOVE; + } + + public void setPark() { + this.status = VehicleStatus.PARK; + } + + public void setStop() { + this.status = VehicleStatus.STOP; + } + + public VehicleStatus getStatus() { + return status; + } + + public int getNumberOfWheels() { + return NumberOfWheels; + } + + public String getId() { + return id; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Vehicle{"); + sb.append("status=").append(status); + sb.append(", NumberOfWheels=").append(NumberOfWheels); + sb.append(", id='").append(id).append('\''); + sb.append('}'); + return sb.toString(); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Vehicle vehicle)) return false; + return Objects.equals(id, vehicle.id); + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } +} diff --git a/ora4/proj1/untitled/src/hu/unideb/inf/pv/VehicleStatus.java b/ora4/proj1/untitled/src/hu/unideb/inf/pv/VehicleStatus.java new file mode 100644 index 0000000..c2d04e1 --- /dev/null +++ b/ora4/proj1/untitled/src/hu/unideb/inf/pv/VehicleStatus.java @@ -0,0 +1,7 @@ +package hu.unideb.inf.pv; + +public enum VehicleStatus { + MOVE, + STOP, + PARK; +} diff --git a/ora4/proj1/untitled/untitled.iml b/ora4/proj1/untitled/untitled.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/ora4/proj1/untitled/untitled.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ora4/proj2/untitled/.gitignore b/ora4/proj2/untitled/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/ora4/proj2/untitled/.gitignore @@ -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 \ No newline at end of file diff --git a/ora4/proj2/untitled/.idea/.gitignore b/ora4/proj2/untitled/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/ora4/proj2/untitled/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/ora4/proj2/untitled/.idea/misc.xml b/ora4/proj2/untitled/.idea/misc.xml new file mode 100644 index 0000000..41d2c62 --- /dev/null +++ b/ora4/proj2/untitled/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora4/proj2/untitled/.idea/modules.xml b/ora4/proj2/untitled/.idea/modules.xml new file mode 100644 index 0000000..3007dae --- /dev/null +++ b/ora4/proj2/untitled/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ora4/proj2/untitled/.idea/vcs.xml b/ora4/proj2/untitled/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/ora4/proj2/untitled/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ora4/proj2/untitled/src/Runner.java b/ora4/proj2/untitled/src/Runner.java new file mode 100644 index 0000000..4a6f9a9 --- /dev/null +++ b/ora4/proj2/untitled/src/Runner.java @@ -0,0 +1,21 @@ +import hu.unideb.inf.ps.EgyenloOldaluHaromszog; +import hu.unideb.inf.ps.Negyzet; +import hu.unideb.inf.ps.Sokszog; +import hu.unideb.inf.ps.Teglalap; + +public class Runner { + public static void main() { + EgyenloOldaluHaromszog h1 = new EgyenloOldaluHaromszog(10); + Sokszog h2 = new EgyenloOldaluHaromszog(11); + ((EgyenloOldaluHaromszog)h2).getOldalhossz(); + System.out.println(h1); + System.out.println(h2); + + Teglalap t1 = new Teglalap(5,6); + Sokszog t2 = new Teglalap(20, 10); + //t2.getRovidebbOldal(); //nincs mivel sokszog tipuskent lett deklaralva + + Negyzet n1 = new Negyzet(4); + Sokszog n2 = new Negyzet(6); + } +} diff --git a/ora4/proj2/untitled/src/hu/unideb/inf/ps/EgyenloOldaluHaromszog.java b/ora4/proj2/untitled/src/hu/unideb/inf/ps/EgyenloOldaluHaromszog.java new file mode 100644 index 0000000..0bc0696 --- /dev/null +++ b/ora4/proj2/untitled/src/hu/unideb/inf/ps/EgyenloOldaluHaromszog.java @@ -0,0 +1,33 @@ +package hu.unideb.inf.ps; + +public class EgyenloOldaluHaromszog extends Sokszog{ + private double oldalhossz; + + public EgyenloOldaluHaromszog(double oldalhossz) { + super(3); + this.oldalhossz = oldalhossz; + } + + public double getOldalhossz() { + return oldalhossz; + } + + @Override + public double kerulet() { + return 3 * getOldalhossz(); + } + + @Override + public double terulet() { + return getOldalhossz() * getOldalhossz() * Math.sqrt(3)/4; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("EgyenloOldaluHaromszog{"); + sb.append(super.toString()); + sb.append("oldalhossz=").append(oldalhossz); + sb.append('}'); + return sb.toString(); + } +} diff --git a/ora4/proj2/untitled/src/hu/unideb/inf/ps/Negyzet.java b/ora4/proj2/untitled/src/hu/unideb/inf/ps/Negyzet.java new file mode 100644 index 0000000..f186848 --- /dev/null +++ b/ora4/proj2/untitled/src/hu/unideb/inf/ps/Negyzet.java @@ -0,0 +1,22 @@ +package hu.unideb.inf.ps; + +public class Negyzet extends Teglalap{ + public Negyzet(double oldal) { + super(oldal, oldal); + } + + public double getOldal() { + return super.getHosszabbOldal(); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Negyzet{"); + sb.append("oldal = ").append(getOldal()); + sb.append(" kerulet = ").append(kerulet()); + sb.append(" terulet = ").append(terulet()); + sb.append(" szogek szama = ").append(getSzogekSzama()); + sb.append('}'); + return sb.toString(); + } +} diff --git a/ora4/proj2/untitled/src/hu/unideb/inf/ps/Sokszog.java b/ora4/proj2/untitled/src/hu/unideb/inf/ps/Sokszog.java new file mode 100644 index 0000000..4494966 --- /dev/null +++ b/ora4/proj2/untitled/src/hu/unideb/inf/ps/Sokszog.java @@ -0,0 +1,26 @@ +package hu.unideb.inf.ps; + +public abstract class Sokszog { + private int szogekSzama; + + public Sokszog(int szogekSzama) { + this.szogekSzama = szogekSzama; + } + + public int getSzogekSzama() { + return szogekSzama; + } + + public abstract double kerulet(); + public abstract double terulet(); + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Sokszog{"); + sb.append("szogekSzama=").append(szogekSzama); + sb.append("kerulet = ").append(this.kerulet()); + sb.append("terulet = ").append(this.terulet()); + sb.append('}'); + return sb.toString(); + } +} diff --git a/ora4/proj2/untitled/src/hu/unideb/inf/ps/Teglalap.java b/ora4/proj2/untitled/src/hu/unideb/inf/ps/Teglalap.java new file mode 100644 index 0000000..798da99 --- /dev/null +++ b/ora4/proj2/untitled/src/hu/unideb/inf/ps/Teglalap.java @@ -0,0 +1,46 @@ +package hu.unideb.inf.ps; + +public class Teglalap extends Sokszog{ + private double hosszabbOldal; + private double rovidebbOldal; + + public Teglalap(double rovidebbOldal, double hosszabbOldal) { + super(4); + + if(hosszabbOldal < rovidebbOldal){ + this.hosszabbOldal = rovidebbOldal; + this.rovidebbOldal = hosszabbOldal; + }else{ + this.rovidebbOldal = rovidebbOldal; + this.hosszabbOldal = hosszabbOldal; + } + } + + public double getHosszabbOldal() { + return hosszabbOldal; + } + + public double getRovidebbOldal() { + return rovidebbOldal; + } + + @Override + public double kerulet() { + return 2*(rovidebbOldal+hosszabbOldal); + } + + @Override + public double terulet() { + return rovidebbOldal*hosszabbOldal; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Teglalap{"); + sb.append(super.toString()); + sb.append("hosszabbOldal=").append(hosszabbOldal); + sb.append(", rovidebbOldal=").append(rovidebbOldal); + sb.append('}'); + return sb.toString(); + } +} diff --git a/ora4/proj2/untitled/untitled.iml b/ora4/proj2/untitled/untitled.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/ora4/proj2/untitled/untitled.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file