added java & fixed z7
This commit is contained in:
parent
4fc3b7661f
commit
1287b0deaa
24
Jerzy/Okno.java
Normal file
24
Jerzy/Okno.java
Normal file
@ -0,0 +1,24 @@
|
||||
package POB_2019.Jerzy;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JButton;
|
||||
import java.awt.*;
|
||||
|
||||
public class Okno extends JFrame {
|
||||
public Okno(){
|
||||
super("Moje okno");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setPreferredSize(new Dimension(500,500));
|
||||
setLocation(100,100);
|
||||
setVisible(true);
|
||||
}
|
||||
@Override
|
||||
public void paintComponents(Graphics g){
|
||||
super.paintComponents(g);
|
||||
Graphics g2 = (Graphics2D) g;
|
||||
g2.drawOval(10,10, 490, 490);
|
||||
g2.drawRect(100,100, 400, 400);
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
13
Jerzy/main.java
Normal file
13
Jerzy/main.java
Normal file
@ -0,0 +1,13 @@
|
||||
package POB_2019.Jerzy;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
public class main {
|
||||
public static void main (String[] args){
|
||||
EventQueue.invokeLater(new Runnable(){
|
||||
public void run(){
|
||||
new Okno();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
BIN
Kolokwium 15.04/a.out
Executable file
BIN
Kolokwium 15.04/a.out
Executable file
Binary file not shown.
2
Kolokwium 15.04/kolo/geometry/Makefile
Normal file
2
Kolokwium 15.04/kolo/geometry/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
geometry: geometry.cpp
|
||||
g++ --std=c++14 $< -o $@
|
57
Kolokwium 15.04/kolo/geometry/geometry.cpp
Normal file
57
Kolokwium 15.04/kolo/geometry/geometry.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
class Geometry {
|
||||
public:
|
||||
virtual string type()=0;
|
||||
virtual float volume()=0;
|
||||
};
|
||||
|
||||
class Box : public Geometry {
|
||||
private:
|
||||
int dimX, dimY, dimZ;
|
||||
public:
|
||||
Box(int _dimX, int _dimY, int _dimZ){
|
||||
dimX=_dimX;
|
||||
dimY=_dimY;
|
||||
dimZ=_dimZ;
|
||||
}
|
||||
virtual string type(){
|
||||
return "Box";
|
||||
}
|
||||
virtual float volume(){
|
||||
return(dimX*dimZ*dimY);
|
||||
}
|
||||
};
|
||||
|
||||
class Ball : public Geometry {
|
||||
private:
|
||||
int radius;
|
||||
public:
|
||||
Ball(int _radius){
|
||||
radius=_radius;
|
||||
}
|
||||
virtual string type(){
|
||||
return "Ball";
|
||||
}
|
||||
virtual float volume(){
|
||||
return (float)4/3*M_PI*pow(radius, 3);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
vector<Geometry*> geometries = {
|
||||
(Geometry*)new Box(10, 2, 3),
|
||||
(Geometry*)new Box(3, 3, 1),
|
||||
(Geometry*)new Ball(5),
|
||||
(Geometry*)new Ball(1)
|
||||
};
|
||||
for (Geometry *f : geometries) {
|
||||
cout << f->type() << ": volume = " << f->volume() << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
56
Kolokwium 15.04/kolo/parking/parking.py
Normal file
56
Kolokwium 15.04/kolo/parking/parking.py
Normal file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
class Owner():
|
||||
def __init__(self, _name, _surname):
|
||||
self.name=_name
|
||||
self.surname=_surname
|
||||
def __str__(self):
|
||||
return "%s %s" % (self.name, self.surname)
|
||||
|
||||
class Car(Owner):
|
||||
def __init__(self, _brand, _owner):
|
||||
self.brand=_brand
|
||||
self.owner=_owner
|
||||
def __str__(self):
|
||||
return "%s, %s %s" % (self.brand, self.owner.name, self.owner.surname)
|
||||
|
||||
class Parking(Car):
|
||||
def __init__(self, _parkingSpaces):
|
||||
self.cars=[]
|
||||
self.parkingSpaces=_parkingSpaces
|
||||
def addCar(self, car):
|
||||
if len(self.cars)>=self.parkingSpaces:
|
||||
return;
|
||||
else:
|
||||
self.cars.append(car)
|
||||
def removeCar(self, selectedCar):
|
||||
if selectedCar in self.cars:
|
||||
self.cars.remove(selectedCar)
|
||||
def count(self):
|
||||
return str(len(self.cars))
|
||||
def freePlaces(self):
|
||||
return str(self.parkingSpaces-len(self.cars))
|
||||
def __str__(self):
|
||||
sStream=''
|
||||
sStream=sStream + str(len(self.cars)) + ' cars:\n'
|
||||
for car in self.cars:
|
||||
sStream=sStream + str(car) + '\n'
|
||||
return sStream
|
||||
parking = Parking(3)
|
||||
|
||||
owner1 = Owner("Jan", "Sienkiewicz")
|
||||
owner2 = Owner("Marek", "Kowalski")
|
||||
|
||||
car1 = Car("Renault", owner1)
|
||||
car2 = Car("BMW", owner2)
|
||||
car3 = Car("Opel", owner1)
|
||||
car4 = Car("Mercedes", owner1)
|
||||
|
||||
parking.addCar(car1)
|
||||
parking.addCar(car2)
|
||||
parking.addCar(car3)
|
||||
parking.addCar(car4)
|
||||
parking.removeCar(car3)
|
||||
parking.addCar(car4)
|
||||
|
||||
print(parking)
|
BIN
Kolokwium 15.04/kolo/s444409_kol.zip
Normal file
BIN
Kolokwium 15.04/kolo/s444409_kol.zip
Normal file
Binary file not shown.
BIN
Kolokwium 15.04/zad1
Executable file
BIN
Kolokwium 15.04/zad1
Executable file
Binary file not shown.
57
Kolokwium 15.04/zad1.cpp
Normal file
57
Kolokwium 15.04/zad1.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
class Geometry {
|
||||
public:
|
||||
virtual string type()=0;
|
||||
virtual float volume()=0;
|
||||
};
|
||||
|
||||
class Box : public Geometry {
|
||||
private:
|
||||
int dimX, dimY, dimZ;
|
||||
public:
|
||||
Box(int _dimX, int _dimY, int _dimZ){
|
||||
dimX=_dimX;
|
||||
dimY=_dimY;
|
||||
dimZ=_dimZ;
|
||||
}
|
||||
virtual string type(){
|
||||
return "Box";
|
||||
}
|
||||
virtual float volume(){
|
||||
return(dimX*dimZ*dimY);
|
||||
}
|
||||
};
|
||||
|
||||
class Ball : public Geometry {
|
||||
private:
|
||||
int radius;
|
||||
public:
|
||||
Ball(int _radius){
|
||||
radius=_radius;
|
||||
}
|
||||
virtual string type(){
|
||||
return "Ball";
|
||||
}
|
||||
virtual float volume(){
|
||||
return (float)4/3*M_PI*pow(radius, 3);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
vector<Geometry*> geometries = {
|
||||
(Geometry*)new Box(10, 2, 3),
|
||||
(Geometry*)new Box(3, 3, 1),
|
||||
(Geometry*)new Ball(5),
|
||||
(Geometry*)new Ball(1)
|
||||
};
|
||||
for (Geometry *f : geometries) {
|
||||
cout << f->type() << ": volume = " << f->volume() << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
56
Kolokwium 15.04/zad2.py
Normal file
56
Kolokwium 15.04/zad2.py
Normal file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
class Owner():
|
||||
def __init__(self, _name, _surname):
|
||||
self.name=_name
|
||||
self.surname=_surname
|
||||
def __str__(self):
|
||||
return "%s %s" % (self.name, self.surname)
|
||||
|
||||
class Car(Owner):
|
||||
def __init__(self, _brand, _owner):
|
||||
self.brand=_brand
|
||||
self.owner=_owner
|
||||
def __str__(self):
|
||||
return "%s, %s %s" % (self.brand, self.owner.name, self.owner.surname)
|
||||
|
||||
class Parking(Car):
|
||||
def __init__(self, _parkingSpaces):
|
||||
self.cars=[]
|
||||
self.parkingSpaces=_parkingSpaces
|
||||
def addCar(self, car):
|
||||
if len(self.cars)>=self.parkingSpaces:
|
||||
return;
|
||||
else:
|
||||
self.cars.append(car)
|
||||
def removeCar(self, selectedCar):
|
||||
if selectedCar in self.cars:
|
||||
self.cars.remove(selectedCar)
|
||||
def count(self):
|
||||
return str(len(self.cars))
|
||||
def freePlaces(self):
|
||||
return str(self.parkingSpaces-len(self.cars))
|
||||
def __str__(self):
|
||||
sStream=''
|
||||
sStream=sStream + str(len(self.cars)) + ' cars:\n'
|
||||
for car in self.cars:
|
||||
sStream=sStream + str(car) + '\n'
|
||||
return sStream
|
||||
parking = Parking(3)
|
||||
|
||||
owner1 = Owner("Jan", "Sienkiewicz")
|
||||
owner2 = Owner("Marek", "Kowalski")
|
||||
|
||||
car1 = Car("Renault", owner1)
|
||||
car2 = Car("BMW", owner2)
|
||||
car3 = Car("Opel", owner1)
|
||||
car4 = Car("Mercedes", owner1)
|
||||
|
||||
parking.addCar(car1)
|
||||
parking.addCar(car2)
|
||||
parking.addCar(car3)
|
||||
parking.addCar(car4)
|
||||
parking.removeCar(car3)
|
||||
parking.addCar(car4)
|
||||
|
||||
print(parking)
|
BIN
POB_Java/Employee.class
Normal file
BIN
POB_Java/Employee.class
Normal file
Binary file not shown.
45
POB_Java/Employee.java
Normal file
45
POB_Java/Employee.java
Normal file
@ -0,0 +1,45 @@
|
||||
import java.io.*;
|
||||
public class Employee {
|
||||
|
||||
String name;
|
||||
int age;
|
||||
String designation;
|
||||
double salary;
|
||||
|
||||
// This is the constructor of the class Employee
|
||||
public Employee(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// Assign the age of the Employee to the variable age.
|
||||
public void empAge(int empAge) {
|
||||
age = empAge;
|
||||
}
|
||||
|
||||
/* Assign the designation to the variable designation.*/
|
||||
public void empDesignation(String empDesig) {
|
||||
designation = empDesig;
|
||||
}
|
||||
|
||||
/* Assign the salary to the variable salary.*/
|
||||
public void empSalary(double empSalary) {
|
||||
salary = empSalary;
|
||||
}
|
||||
|
||||
/* Print the Employee details */
|
||||
public void printEmployee() {
|
||||
System.out.println("Name:"+ name );
|
||||
System.out.println("Age:" + age );
|
||||
System.out.println("Designation:" + designation );
|
||||
System.out.println("Salary:" + salary);
|
||||
}
|
||||
public void compare(Employee emp){
|
||||
if(emp.salary > this.salary){
|
||||
System.out.println("Second employee earns more.");
|
||||
} else if (emp.salary < this.salary){
|
||||
System.out.println("First employee earns more.");
|
||||
} else {
|
||||
System.out.println("Both employees earn the same ammount.");
|
||||
}
|
||||
}
|
||||
}
|
BIN
POB_Java/Employee_main.class
Normal file
BIN
POB_Java/Employee_main.class
Normal file
Binary file not shown.
10
POB_Java/Employee_main.java
Normal file
10
POB_Java/Employee_main.java
Normal file
@ -0,0 +1,10 @@
|
||||
public class Employee_main{
|
||||
public static void main(String []args){
|
||||
Employee emp1=new Employee("Marcin");
|
||||
emp1.salary=1500;
|
||||
Employee emp2=new Employee("Tomasz");
|
||||
emp2.salary=1900;
|
||||
emp1.compare(emp2);
|
||||
|
||||
}
|
||||
}
|
59
zad7_1.cpp
Normal file
59
zad7_1.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Vec2 {
|
||||
private:
|
||||
int x,y;
|
||||
public:
|
||||
Vec2(int _x, int _y){
|
||||
x=_x;
|
||||
y=_y;
|
||||
}
|
||||
string toString(){
|
||||
stringstream s;
|
||||
s << "[" << x << ", " << y << "]";
|
||||
return s.str();
|
||||
}
|
||||
friend Vec2 operator+(const Vec2& vec1, const Vec2& vec2){
|
||||
return Vec2(vec1.x+vec2.x, vec1.y+vec2.y);
|
||||
}
|
||||
friend Vec2 operator-(const Vec2& vec1, const Vec2& vec2){
|
||||
return Vec2(vec1.x-vec2.x, vec1.y-vec2.y);
|
||||
}
|
||||
Vec2& operator+=(const Vec2& vec){
|
||||
x=vec.x+x;
|
||||
y=vec.y+y;
|
||||
return *this;
|
||||
}
|
||||
Vec2& operator-=(const Vec2& vec){
|
||||
x=vec.x-x;
|
||||
y=vec.y-y;
|
||||
return *this;
|
||||
}
|
||||
friend float operator*(const Vec2& vec1, const Vec2& vec2){
|
||||
return (float)vec1.x*vec2.x + (float)vec1.y+vec2.y;
|
||||
}
|
||||
bool operator==(const Vec2& vec){
|
||||
if(x==vec.x && y==vec.y) return 1;
|
||||
else return 0;
|
||||
}
|
||||
bool operator!=(const Vec2& vec){
|
||||
if(x==vec.x && y==vec.y) return 0;
|
||||
else return 1;
|
||||
}
|
||||
};
|
||||
|
||||
int main(){
|
||||
Vec2 vec1 = Vec2(5,1);
|
||||
Vec2 vec2 = Vec2(3,4);
|
||||
Vec2 vec3 = vec1 + vec2;
|
||||
cout << vec3.toString() << endl;
|
||||
vec3+=vec2;
|
||||
cout << vec3.toString() << endl;
|
||||
vec3-=vec1;
|
||||
cout << vec3.toString() << endl;
|
||||
cout << vec3*vec2 << endl;
|
||||
}
|
34
zad7_2.cpp
Normal file
34
zad7_2.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename num>
|
||||
class Vec2 {
|
||||
private:
|
||||
num x,y;
|
||||
public:
|
||||
Vec2(num _x, num _y){
|
||||
x=_x;
|
||||
y=_y;
|
||||
}
|
||||
string toString(){
|
||||
stringstream s;
|
||||
s << "[" << x << ", " << y << "]";
|
||||
return s.str();
|
||||
}
|
||||
Vec2 add(const Vec2& vec){
|
||||
return Vec2(x+vec.x, y+vec.y);
|
||||
}
|
||||
num multiply(const Vec2& vec){
|
||||
return (float)x*vec.x + (float)y*vec.y;
|
||||
}
|
||||
};
|
||||
|
||||
int main(){
|
||||
Vec2<float> vec1 = Vec2<float>(5.5f,1.2f);
|
||||
Vec2<float> vec2 = Vec2<float>(3.4f,4.2f);
|
||||
Vec2<float> vec3 = vec1.add(vec2);
|
||||
cout << vec3.toString() << endl;
|
||||
}
|
Loading…
Reference in New Issue
Block a user