diff --git a/Jerzy/Okno.java b/Jerzy/Okno.java new file mode 100644 index 0000000..4fbef0e --- /dev/null +++ b/Jerzy/Okno.java @@ -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); + } +} \ No newline at end of file diff --git a/Jerzy/main.java b/Jerzy/main.java new file mode 100644 index 0000000..265d671 --- /dev/null +++ b/Jerzy/main.java @@ -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(); + } + }); + } +} \ No newline at end of file diff --git a/Kolokwium 15.04/a.out b/Kolokwium 15.04/a.out new file mode 100755 index 0000000..1fd335c Binary files /dev/null and b/Kolokwium 15.04/a.out differ diff --git a/Kolokwium 15.04/kolo/geometry/Makefile b/Kolokwium 15.04/kolo/geometry/Makefile new file mode 100644 index 0000000..7b19b32 --- /dev/null +++ b/Kolokwium 15.04/kolo/geometry/Makefile @@ -0,0 +1,2 @@ +geometry: geometry.cpp + g++ --std=c++14 $< -o $@ diff --git a/Kolokwium 15.04/kolo/geometry/geometry.cpp b/Kolokwium 15.04/kolo/geometry/geometry.cpp new file mode 100644 index 0000000..3a54b68 --- /dev/null +++ b/Kolokwium 15.04/kolo/geometry/geometry.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include +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 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; +} \ No newline at end of file diff --git a/Kolokwium 15.04/kolo/parking/parking.py b/Kolokwium 15.04/kolo/parking/parking.py new file mode 100644 index 0000000..ec0f496 --- /dev/null +++ b/Kolokwium 15.04/kolo/parking/parking.py @@ -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) \ No newline at end of file diff --git a/Kolokwium 15.04/kolo/s444409_kol.zip b/Kolokwium 15.04/kolo/s444409_kol.zip new file mode 100644 index 0000000..aee2bbc Binary files /dev/null and b/Kolokwium 15.04/kolo/s444409_kol.zip differ diff --git a/Kolokwium 15.04/zad1 b/Kolokwium 15.04/zad1 new file mode 100755 index 0000000..1fd335c Binary files /dev/null and b/Kolokwium 15.04/zad1 differ diff --git a/Kolokwium 15.04/zad1.cpp b/Kolokwium 15.04/zad1.cpp new file mode 100644 index 0000000..3a54b68 --- /dev/null +++ b/Kolokwium 15.04/zad1.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include +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 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; +} \ No newline at end of file diff --git a/Kolokwium 15.04/zad2.py b/Kolokwium 15.04/zad2.py new file mode 100644 index 0000000..ec0f496 --- /dev/null +++ b/Kolokwium 15.04/zad2.py @@ -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) \ No newline at end of file diff --git a/POB_Java/Employee.class b/POB_Java/Employee.class new file mode 100644 index 0000000..ed1893a Binary files /dev/null and b/POB_Java/Employee.class differ diff --git a/POB_Java/Employee.java b/POB_Java/Employee.java new file mode 100644 index 0000000..3e008c4 --- /dev/null +++ b/POB_Java/Employee.java @@ -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."); + } + } +} \ No newline at end of file diff --git a/POB_Java/Employee_main.class b/POB_Java/Employee_main.class new file mode 100644 index 0000000..e161e47 Binary files /dev/null and b/POB_Java/Employee_main.class differ diff --git a/POB_Java/Employee_main.java b/POB_Java/Employee_main.java new file mode 100644 index 0000000..b05038b --- /dev/null +++ b/POB_Java/Employee_main.java @@ -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); + + } +} \ No newline at end of file diff --git a/zad7_1 b/zad7_1 new file mode 100755 index 0000000..c9c2160 Binary files /dev/null and b/zad7_1 differ diff --git a/zad7_1.cpp b/zad7_1.cpp new file mode 100644 index 0000000..7dced9e --- /dev/null +++ b/zad7_1.cpp @@ -0,0 +1,59 @@ +#include +#include +#include + +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; +} \ No newline at end of file diff --git a/zad7_2.cpp b/zad7_2.cpp new file mode 100644 index 0000000..60aa8f7 --- /dev/null +++ b/zad7_2.cpp @@ -0,0 +1,34 @@ +#include +#include +#include + +using namespace std; + +template +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 vec1 = Vec2(5.5f,1.2f); + Vec2 vec2 = Vec2(3.4f,4.2f); + Vec2 vec3 = vec1.add(vec2); + cout << vec3.toString() << endl; +} \ No newline at end of file