ora4
This commit is contained in:
2
ora3/iproj1/untitled/.idea/misc.xml
generated
2
ora3/iproj1/untitled/.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_24" default="true" project-jdk-name="24" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_24" project-jdk-name="24" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
29
ora4/proj1/untitled/.gitignore
vendored
Normal file
29
ora4/proj1/untitled/.gitignore
vendored
Normal file
@@ -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
ora4/proj1/untitled/.idea/.gitignore
generated
vendored
Normal file
3
ora4/proj1/untitled/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
ora4/proj1/untitled/.idea/misc.xml
generated
Normal file
6
ora4/proj1/untitled/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_24" project-jdk-name="24" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
ora4/proj1/untitled/.idea/modules.xml
generated
Normal file
8
ora4/proj1/untitled/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/untitled.iml" filepath="$PROJECT_DIR$/untitled.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
ora4/proj1/untitled/.idea/vcs.xml
generated
Normal file
6
ora4/proj1/untitled/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
33
ora4/proj1/untitled/src/Runner.java
Normal file
33
ora4/proj1/untitled/src/Runner.java
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
26
ora4/proj1/untitled/src/hu/unideb/inf/pv/Bicycle.java
Normal file
26
ora4/proj1/untitled/src/hu/unideb/inf/pv/Bicycle.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
64
ora4/proj1/untitled/src/hu/unideb/inf/pv/Car.java
Normal file
64
ora4/proj1/untitled/src/hu/unideb/inf/pv/Car.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
64
ora4/proj1/untitled/src/hu/unideb/inf/pv/Vehicle.java
Normal file
64
ora4/proj1/untitled/src/hu/unideb/inf/pv/Vehicle.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package hu.unideb.inf.pv;
|
||||
|
||||
public enum VehicleStatus {
|
||||
MOVE,
|
||||
STOP,
|
||||
PARK;
|
||||
}
|
||||
11
ora4/proj1/untitled/untitled.iml
Normal file
11
ora4/proj1/untitled/untitled.iml
Normal file
@@ -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>
|
||||
29
ora4/proj2/untitled/.gitignore
vendored
Normal file
29
ora4/proj2/untitled/.gitignore
vendored
Normal file
@@ -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
ora4/proj2/untitled/.idea/.gitignore
generated
vendored
Normal file
3
ora4/proj2/untitled/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
ora4/proj2/untitled/.idea/misc.xml
generated
Normal file
6
ora4/proj2/untitled/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="24" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
ora4/proj2/untitled/.idea/modules.xml
generated
Normal file
8
ora4/proj2/untitled/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/untitled.iml" filepath="$PROJECT_DIR$/untitled.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
ora4/proj2/untitled/.idea/vcs.xml
generated
Normal file
6
ora4/proj2/untitled/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
21
ora4/proj2/untitled/src/Runner.java
Normal file
21
ora4/proj2/untitled/src/Runner.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
22
ora4/proj2/untitled/src/hu/unideb/inf/ps/Negyzet.java
Normal file
22
ora4/proj2/untitled/src/hu/unideb/inf/ps/Negyzet.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
26
ora4/proj2/untitled/src/hu/unideb/inf/ps/Sokszog.java
Normal file
26
ora4/proj2/untitled/src/hu/unideb/inf/ps/Sokszog.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
46
ora4/proj2/untitled/src/hu/unideb/inf/ps/Teglalap.java
Normal file
46
ora4/proj2/untitled/src/hu/unideb/inf/ps/Teglalap.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
11
ora4/proj2/untitled/untitled.iml
Normal file
11
ora4/proj2/untitled/untitled.iml
Normal file
@@ -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>
|
||||
Reference in New Issue
Block a user