Skip to content

Instantly share code, notes, and snippets.

@MicicFilip
Created March 24, 2016 19:11
Show Gist options
  • Save MicicFilip/02ce0ed6f2fddd121473 to your computer and use it in GitHub Desktop.
Save MicicFilip/02ce0ed6f2fddd121473 to your computer and use it in GitHub Desktop.
#! C:\Strawberry\perl\bin\perl.exe
use warnings;
use strict;
use v5.010;
use main2;
my $operation1 = new VectorPrvi(10 , 20 , 30);
my $prviX = $operation1->getX();
my $prviY = $operation1->getY();
my $prviZ = $operation1->getZ();
my $operation2 = new VectorPrvi(40, 50, 60);
my $drugiX = $operation2->getX();
my $drugiY = $operation2->getY();
my $drugiZ = $operation2->getZ();
my $zbirX = $prviX + $drugiX;
my $zbirY = $prviY + $drugiY;
my $zbirZ = $prviZ + $drugiZ;
say "Sabrani vektori: $zbirX , $zbirY , $zbirZ";
my $oduzetiX = $prviX - $drugiX;
my $oduzetiY = $prviY - $drugiY;
my $oduzetiZ = $prviZ - $drugiZ;
say "Oduzeti vektori: $oduzetiX, $oduzetiY, $oduzetiZ";
my $pomnozeniX = $prviX * $drugiX;
my $pomnozeniY = $prviY * $drugiY;
my $pomnozeniZ = $prviZ * $drugiZ;
say "Pomnozeni vektori: $pomnozeniX, $pomnozeniY, $pomnozeniZ";
my $podeljeniX = $prviX / $drugiX;
my $podeljeniY = $prviY / $drugiY;
my $podeljeniZ = $prviZ / $drugiZ;
say "Podeljeni vektori: $podeljeniX, $podeljeniY, $podeljeniZ";
#! C:\Strawberry\perl\bin\perl.exe
use warnings;
use strict;
use v5.010;
package VectorPrvi;
sub new {
my $class = shift;
my $self = {
_x => shift,
_y => shift,
_z => shift
};
sub getX {
my ($self) = shift;
return $self->{_x};
}
sub getY {
my ($self) = shift;
return $self->{_y};
}
sub getZ {
my ($self) = shift;
return $self->{_z};
}
bless $self, $class;
return $self;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment