Compare commits
No commits in common. "master" and "master" have entirely different histories.
@ -1,27 +0,0 @@
|
||||
TARGET := figures
|
||||
|
||||
BUILD_DIR := bin
|
||||
SRC_DIR := source
|
||||
INC_DIR := include
|
||||
|
||||
SRCS := $(shell find $(SRC_DIR) -name *.cpp)
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIR))
|
||||
|
||||
CPPFLAGS := $(INC_FLAGS) --std=c++14
|
||||
|
||||
|
||||
$(BUILD_DIR)/$(TARGET): $(OBJS)
|
||||
echo $(LDFLAGS)
|
||||
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
|
||||
|
||||
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)/*
|
Binary file not shown.
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Figure.h"
|
||||
#include <string>
|
||||
|
||||
class Circle : public Figure {
|
||||
public:
|
||||
float r;
|
||||
Circle();
|
||||
Circle(float _r);
|
||||
virtual std::string type() const;
|
||||
virtual float area() const;
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class Figure {
|
||||
public:
|
||||
virtual std::string type() const = 0;
|
||||
virtual float area() const = 0;
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Figure.h"
|
||||
#include <string>
|
||||
|
||||
class Rectangle : public Figure {
|
||||
public:
|
||||
float w,h;
|
||||
Rectangle();
|
||||
Rectangle(float _w, float _h);
|
||||
virtual std::string type() const;
|
||||
virtual float area() const;
|
||||
};
|
@ -1,19 +0,0 @@
|
||||
#include "../include/Circle.h"
|
||||
#include <string>
|
||||
|
||||
#define PI 3.141592653589793238463
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Circle::Circle(){r=0;}
|
||||
|
||||
Circle::Circle(float _r){r=_r;}
|
||||
|
||||
string Circle::type() const {
|
||||
return "Circle";
|
||||
}
|
||||
|
||||
float Circle::area() const {
|
||||
return PI * r * r;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#include "../include/Rectangle.h"
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
Rectangle::Rectangle() : w(0), h(0) {}
|
||||
|
||||
Rectangle::Rectangle(float _w, float _h) : w(_w), h(_h) {}
|
||||
|
||||
string Rectangle::type() const {
|
||||
return "Rectangle";
|
||||
}
|
||||
|
||||
float Rectangle::area() const {
|
||||
return w * h;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#include "../include/Circle.h"
|
||||
#include "../include/Rectangle.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
vector<Figure*> figures = {
|
||||
(Figure*)new Rectangle(10, 2),
|
||||
(Figure*)new Rectangle(3, 3),
|
||||
(Figure*)new Circle(5),
|
||||
(Figure*)new Circle(1)
|
||||
};
|
||||
for (Figure *f : figures) {
|
||||
cout << f->type() << ": area = " << f->area() << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package POB_2019.Java.zad1_1;
|
||||
|
||||
public class Przedmiot {
|
||||
private String subjectName;
|
||||
public Przedmiot(String name){
|
||||
this.subjectName=name;
|
||||
}
|
||||
public String toString(){
|
||||
return this.subjectName + "JEchane";
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package POB_2019.Java.zad1_1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class zad1_1 {
|
||||
public static void main(String[] args) {
|
||||
List<Przedmiot> subjects = new ArrayList<Przedmiot>();
|
||||
subjects.add(new Przedmiot("Ball"));
|
||||
subjects.add(new Przedmiot("Chair"));
|
||||
subjects.add(new Przedmiot("Table"));
|
||||
for(Przedmiot p : subjects){
|
||||
System.out.println(p);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package POB_2019.Java.zad1_2;
|
||||
|
||||
public class Vector2D {
|
||||
private int x, y;
|
||||
public Vector2D(int _x, int _y){
|
||||
this.x=_x;
|
||||
this.y=_y;
|
||||
}
|
||||
public Vector2D add(Vector2D vec2){
|
||||
int newX, newY;
|
||||
newX=this.x + vec2.x;
|
||||
newY=this.y + vec2.y;
|
||||
return new Vector2D(newX, newY);
|
||||
}
|
||||
public Vector2D substract(Vector2D vec2){
|
||||
int newX, newY;
|
||||
newX=this.x - vec2.x;
|
||||
newY=this.y - vec2.y;
|
||||
return new Vector2D(newX, newY);
|
||||
}
|
||||
public double multiply(Vector2D vec2){
|
||||
return (this.x*vec2.x + this.y*vec2.y);
|
||||
}
|
||||
public String toString(){
|
||||
return String.format("[%s, %s]", this.x, this.y);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package POB_2019.Java.zad1_2;
|
||||
|
||||
public class zad1_2 {
|
||||
public static void main(String[] args){
|
||||
Vector2D vec1 = new Vector2D(5, 11);
|
||||
Vector2D vec2 = new Vector2D(-2, 4);
|
||||
Vector2D vec3 = vec1.add(vec2);
|
||||
Vector2D vec4 = vec2.substract(vec1);
|
||||
double multiplicationResult = vec2.multiply(vec1);
|
||||
System.out.println(vec3);
|
||||
System.out.println(vec4);
|
||||
System.out.println(multiplicationResult);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package POB_2019.Java.zad2_1;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Koszyk {
|
||||
private List<Produkt> products = new ArrayList<Produkt>();
|
||||
private String name;
|
||||
|
||||
public Koszyk(String _name){
|
||||
this.name=_name;
|
||||
}
|
||||
public void addProduct(Produkt product){
|
||||
products.add(product);
|
||||
}
|
||||
private float totalCost(){
|
||||
float sum=0;
|
||||
for(Produkt p : products)
|
||||
sum+=p.getPrice();
|
||||
return sum;
|
||||
}
|
||||
public String toString(){
|
||||
String fullDesc="Koszyk " + this.name + ":\n";
|
||||
for(Produkt p : products)
|
||||
fullDesc = fullDesc + p.toString();
|
||||
fullDesc = fullDesc + "Total: " + totalCost() + "\n";
|
||||
return fullDesc;
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package POB_2019.Java.zad2_1;
|
||||
|
||||
public class Produkt {
|
||||
private String name;
|
||||
private float price;
|
||||
|
||||
public Produkt(String _name, float _price){
|
||||
this.name=_name;
|
||||
this.price=_price;
|
||||
}
|
||||
public String toString(){
|
||||
return String.format("Nazwa: %s\nCena: %.2f\n\n", this.name, this.price);
|
||||
}
|
||||
public float getPrice(){
|
||||
return this.price;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package POB_2019.Java.zad2_1;
|
||||
|
||||
public class zad2_1 {
|
||||
public static void main(String[] args){
|
||||
Koszyk cart1 = new Koszyk("Marcin");
|
||||
cart1.addProduct(new Produkt("Banan", 3.19f));
|
||||
cart1.addProduct(new Produkt("Ananas", 5.69f));
|
||||
cart1.addProduct(new Produkt("Pomarańcza", 2.99f));
|
||||
System.out.println(cart1);
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package POB_2019.Java.zad3_1;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FileLogger extends Logger {
|
||||
private FileWriter fileWriter;
|
||||
public FileLogger() throws IOException {
|
||||
String fileName = "./log.txt";
|
||||
this.fileWriter = new FileWriter(fileName);
|
||||
}
|
||||
@Override
|
||||
public void log(String textToLog) throws IOException {
|
||||
this.fileWriter.append(textToLog);
|
||||
this.fileWriter.append("\n");
|
||||
fileWriter.flush();
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package POB_2019.Java.zad3_1;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Logger {
|
||||
public void log(String textToLog) throws IOException{};
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package POB_2019.Java.zad3_1;
|
||||
|
||||
public class StdoutLogger extends Logger {
|
||||
@Override
|
||||
public void log(String textToLog){
|
||||
System.out.println(textToLog);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package POB_2019.Java.zad3_1;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class zad3_1 {
|
||||
public static void main(String[] args) throws IOException {
|
||||
Logger log1 = new StdoutLogger();
|
||||
Logger log2 = new FileLogger();
|
||||
List<String> texts = new ArrayList<String>();
|
||||
texts.add("Jechane");
|
||||
texts.add("ASDSAD");
|
||||
texts.add("Jechane1");
|
||||
for(String text : texts){
|
||||
log1.log(text);
|
||||
log2.log(text);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
geometry: geometry.cpp
|
||||
g++ --std=c++14 $< -o $@
|
@ -1,57 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
#!/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)
|
Binary file not shown.
Binary file not shown.
@ -1,57 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
#!/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)
|
1
POB_Java/.gitignore
vendored
1
POB_Java/.gitignore
vendored
@ -1 +0,0 @@
|
||||
*.class
|
Binary file not shown.
@ -1,45 +0,0 @@
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
9
logs/log1.txt
Normal file
9
logs/log1.txt
Normal file
@ -0,0 +1,9 @@
|
||||
cpp1
|
||||
cpp2
|
||||
ilovecpp
|
||||
linuxoverwindows
|
||||
123
|
||||
456
|
||||
789
|
||||
abc
|
||||
qwe
|
9
logs/log2.txt
Normal file
9
logs/log2.txt
Normal file
@ -0,0 +1,9 @@
|
||||
cpp1
|
||||
cpp2
|
||||
ilovecpp
|
||||
linuxoverwindows
|
||||
123
|
||||
456
|
||||
789
|
||||
abc
|
||||
qwe
|
73
zad6_1.cpp
73
zad6_1.cpp
@ -1,73 +0,0 @@
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
#include <opencv2/opencv.hpp>
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
class Shape
|
||||
{
|
||||
public:
|
||||
virtual void draw(Mat &img) = 0;
|
||||
};
|
||||
|
||||
class Circle : public Shape
|
||||
{
|
||||
public:
|
||||
Circle(int x, int y, int r)
|
||||
: _x(x), _y(y), _r(r) {}
|
||||
|
||||
virtual void draw(Mat &img) {
|
||||
circle(img, Point(_x, _y), _r, Scalar(0,0,0));
|
||||
}
|
||||
|
||||
private:
|
||||
int _x, _y, _r;
|
||||
};
|
||||
|
||||
class Rectangle : public Shape
|
||||
{
|
||||
public:
|
||||
Rectangle(int x, int y, int w, int h)
|
||||
: _x(x), _y(y), _w(w), _h(h) {}
|
||||
|
||||
virtual void draw(Mat &img) {
|
||||
rectangle(img, Point(_x, _y),
|
||||
Point(_x+_w, _y+_h), Scalar(0,0,0));
|
||||
}
|
||||
|
||||
private:
|
||||
int _x, _y, _w, _h;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
const char wnd[] = "test";
|
||||
namedWindow(wnd, WINDOW_AUTOSIZE);
|
||||
int width = 1000, height = 800;
|
||||
|
||||
vector<Shape*> shapes {
|
||||
new Circle(300, 200, 100),
|
||||
new Rectangle(500, 200, 300, 100),
|
||||
new Circle(500, 600, 100),
|
||||
new Rectangle(100, 400, 100, 150)
|
||||
};
|
||||
|
||||
Mat img = Mat::zeros(height, width, CV_8UC3);
|
||||
|
||||
while (true)
|
||||
{
|
||||
img = Scalar(255,255,255);
|
||||
for (Shape* shape : shapes) {
|
||||
shape->draw(img);
|
||||
}
|
||||
imshow(wnd, img);
|
||||
int key = waitKey(40);
|
||||
if ((key & 255) == 27) break;
|
||||
}
|
||||
|
||||
for (Shape* shape : shapes) delete shape;
|
||||
shapes.clear();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
40
zad6_2.py
40
zad6_2.py
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
from turtle import *
|
||||
|
||||
class Shape():
|
||||
def __init__(self):
|
||||
pass
|
||||
def draw(self):
|
||||
pass
|
||||
|
||||
class Circle(Shape):
|
||||
def __init__(self, _posX, _posY, _size):
|
||||
self.posX=_posX
|
||||
self.posY=_posY
|
||||
self.size=_size
|
||||
def draw(self):
|
||||
goto(self.posX, self.posY)
|
||||
pendown()
|
||||
circle(self.size)
|
||||
penup()
|
||||
|
||||
class Rect(Shape):
|
||||
def __init__(self, _posX, _posY, _sizeX, _sizeY):
|
||||
self.posX=_posX
|
||||
self.posY=_posY
|
||||
self.sizeX=_sizeX
|
||||
self.sizeY=_sizeY
|
||||
def draw(self):
|
||||
goto(self.posX, self.posY)
|
||||
pendown()
|
||||
for i in range(2):
|
||||
forward(self.sizeX)
|
||||
right(90)
|
||||
forward(self.sizeY)
|
||||
right(90)
|
||||
penup()
|
||||
penup()
|
||||
shapes=[Circle(-200,100,100),
|
||||
Rect(100,100,200,100)]
|
||||
for shape in shapes:
|
||||
shape.draw()
|
59
zad7_1.cpp
59
zad7_1.cpp
@ -1,59 +0,0 @@
|
||||
#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
34
zad7_2.cpp
@ -1,34 +0,0 @@
|
||||
#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;
|
||||
}
|
26
zad7_3.cpp
26
zad7_3.cpp
@ -1,26 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename type>
|
||||
class Array {
|
||||
private:
|
||||
type* basePtr;
|
||||
Array(unsigned int n){
|
||||
basePtr=(type*)malloc(sizeof(type)*n); //allocate the memory
|
||||
}
|
||||
~Array(){
|
||||
free(basePtr);
|
||||
}
|
||||
public:
|
||||
Array& operator new [](unsigned int n){
|
||||
Array(n);
|
||||
return *this;
|
||||
}
|
||||
void* operator delete [](unsigned int n){
|
||||
~Array();
|
||||
}
|
||||
type operator[](){
|
||||
return
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user