Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#include<iostream> using namespace std; //U programu implementirati nasljeđivanje između odgovarajućih klasa class Osoba { protected: char* _ime; char* _prezime; char* _adresa; char _telefon[15]; public: //Potrebne konstruktor i destruktor funkcije Osoba(char* ime=" ", char* prezime=" ", char* adresa=" ", char* telefon=" ") { cout<<"\ninfo::Konstruktor Osoba\n"; int vel = strlen(ime) + 1; _ime = new char[vel]; strcpy_s(_ime, vel, ime); vel = strlen(prezime) + 1; _prezime = new char[vel]; strcpy_s(_prezime, vel, prezime); vel = strlen(adresa) + 1; _adresa = new char[vel]; strcpy_s(_adresa, vel, adresa); strcpy_s(_telefon, 15, telefon); } char* GetIme() { return _ime; } char* GetPrezime() { return _prezime; } virtual ~Osoba() { cout<<"\ninfo::Destruktor Osoba\n"; delete[] _ime; _ime = NULL; delete[] _prezime; _prezime = NULL; delete[] _adresa; _adresa = NULL; } //Klasu deklarisati kao apstraktnu //Kreirati funkciju Info za ispis svih vrijednosti atributa klase virtual void Info()=0; virtual double getmjesecna(){ return 0; } virtual bool izmjena_mp (){ return false; } virtual void izmjena_mail(char* m){} }; class Klijent:public Osoba { protected: int _id; double _mjesecnaPotrosnja; char* _email; public: //Potrebne konstruktor i destruktor funkcije Klijent(char* ime=" ", char* prezime=" ", char* adresa=" ", char* telefon=" ", int id=0, double mp=0, char* email="nepoznato@nepoznato.xx"):Osoba(ime,prezime,adresa,telefon){ cout<<"\ninfo::Konstruktor Klijent\n"; _id=id; _mjesecnaPotrosnja=mp; _email=new char [strlen(email)+1]; strcpy_s(_email,strlen(email)+1, email); } ~Klijent(){ cout<<"\ninfo::Destruktor Klijent\n"; delete []_email; _email=NULL; } //Preklopiti operator > koji će porediti klijenta sa zadatom potrošnjom i //vratiti true u slučaju da je klijent imao veću mjesečnu potrošnju. //Implementirati kao friend funkciju friend bool operator>(Osoba &l, double zadato){ if(l.getmjesecna()>zadato) return true; else return false; } //Kreirati funkciju za izmjenu mail adrese void izmjena_mail(char* m){ delete []_email; _email=new char[strlen(m)+1]; strcpy_s(_email, strlen(m)+1,m); } double getmjesecna(){ return _mjesecnaPotrosnja; } void setmjesecna(double mj){ _mjesecnaPotrosnja=mj; } void Info() { cout<<endl<<"====================================="<<endl; cout << "Ime i prezime: " << _ime << " " << _prezime << endl; cout << "Adresa: " << _adresa<<endl; cout << "Telefon: " << _telefon<<endl; cout << "ID: "<<_id<<endl; cout << "Mjesecna potrosnja: "<<_mjesecnaPotrosnja<<endl; cout << "Email: "<<_email<< endl; cout<<endl<<"====================================="<<endl; } }; class Zaposlenik:public Osoba { char _radnoMjesto[30]; int _godineStaza; public: //Potrebne konstruktor i destruktor funkcije Zaposlenik(char* ime, char* prezime, char* adresa, char* telefon, char *rm, int gs):Osoba(ime,prezime,adresa,telefon){ cout<<"\ninfo::Konstruktor Zaposlenik\n"; strcpy_s(_radnoMjesto,30,rm); _godineStaza=gs; } void Info() { cout<<endl<<"====================================="<<endl; cout << "Ime i prezime: " << _ime << " " << _prezime << endl; cout << "Adresa: " << _adresa<<endl; cout << "Telefon: " << _telefon<<endl; cout << "Radno mjesto: "<<_radnoMjesto<<endl; cout << "Godine staza: "<<_godineStaza<<endl; cout<<endl<<"====================================="<<endl; } //nije potrebno praviti destruktor za ovu podklasu }; class VIPKlijent:public Klijent { double _popust; char* _parkingOznaka; public: //Potrebne konstruktor i destruktor funkcije VIPKlijent(char* ime, char* prezime, char* adresa, char* telefon,int id, double mp,char*email, double p, char* po):Klijent(ime,prezime,adresa,telefon,id, mp, email){ cout<<"\ninfo::Konstruktor VIPKlijent\n"; _popust=p; _parkingOznaka=new char [strlen(po)+1]; strcpy_s(_parkingOznaka,strlen(po)+1, po); } VIPKlijent(VIPKlijent &d):Klijent(d._ime,d._prezime,d._adresa,d._telefon,d._id, d._mjesecnaPotrosnja, d._email){ cout<<"\ninfo::Konstruktor kopije VIPKlijent\n"; _popust=d._popust; _parkingOznaka=new char [strlen(d._parkingOznaka)+1]; strcpy_s(_parkingOznaka,strlen(d._parkingOznaka)+1, d._parkingOznaka); } ~VIPKlijent(){ cout<<"\ninfo::Destruktor VIPKlijent\n"; delete[]_parkingOznaka; } //Funkciju koja treba da izmijeni vrijednost mjesečne potrošnje na način da se //uračuna popust (prosječna potrošnja treba da se umanji) bool izmjena_mp (){ double temp=getmjesecna()-getmjesecna()*(_popust/100); setmjesecna(temp); return true; } //Funkciju za ispis svih vrijednosti atributa klase void Info() { cout<<endl<<"====================================="<<endl; cout << "Ime i prezime: " << _ime << " " << _prezime << endl; cout << "Adresa: " << _adresa<<endl; cout << "Telefon: " << _telefon<<endl; cout << "ID: "<<_id<<endl; cout << "Mjesecna potrosnja: "<<_mjesecnaPotrosnja<<endl; cout << "Email: "<<_email<< endl; cout << "Popust: "<<_popust<<"%"<<endl; cout << "Parking oznaka: "<<_parkingOznaka<<endl; cout<<endl<<"====================================="<<endl; } }; //Funkcija treba da pronađe sve one klijente koji su ostvarili mjesečnu potrošnju veće //od zadate. Ispisati podatke i vratiti ukupan broj pronađenih klijenata double z=100;//Globalna varijabla jer zadata funkcija pretragaPotrosnje ne prima parametar za usporedbu int pretragaPotrosnje(Osoba* niz[], int max){ int brojac=0; for (int i=0;i<max;i++){ if(niz[i]->getmjesecna()>z){ niz[i]->Info(); brojac++; } } return brojac; } //Pronaći sve VIP klijente, te im zaračunati popust na kupljene artikle i ispisati //informacije o onima koji su ostvarili potrošnju preko 50 KM mjesečno void pretragaVIPKlijenata(Osoba* niz[], int max){ for (int i=0;i<max;i++){ if(niz[i]->izmjena_mp()) cout; if(niz[i]->getmjesecna()>50) niz[i]->Info(); } } //Svim klijentima postaviti mail adresu u formatu: ime.prezime@firma.ba //Ime i prezime zamijeniti sa stvarnim vrijednostima. void generisiMailAdrese(Osoba* niz[], int max){ for (int i=0;i<max;i++){ char *email; email=new char[strlen(niz[i]->GetIme())+strlen(niz[i]->GetPrezime())+11]; strcpy(email,niz[i]->GetIme()); strcat(email,"."); strcat(email,niz[i]->GetPrezime()); strcat(email,"@firma.ba\0"); cout<<"test:"<<email; (*niz[i]).izmjena_mail(email); } cout<<"\nNove adrese uspjesno generisane"; } //Omogućiti pretragu klijenata po imenu ili prezimenu (ispisati informacije //o svima koji sadrže uneseni tekst u dijelu imena ili prezimena char* ab="test";//Koristim globalnu jer u postavljenoj funkciji pretragaPoImenu nema parametra za pretrazivanje void pretragaPoImenu(Osoba* niz[], int max){ for (int i=0;i<max;i++){ if ((strcmp(ab,niz[i]->GetIme())==0)||(strcmp(ab,niz[i]->GetPrezime())==0)) niz[i]->Info(); } } void main() { Zaposlenik zap("Mike","Smith","Avalone st.","800-666-626","Desk 03",3); VIPKlijent vip("Roxanne","Copperfield","Downtown st.","800-333-313",1,150,"roxy_coxy@gmail.com",15,"PO-175"); VIPKlijent vip2("Smooth","test","Downtown st. 3","800-555-313",2,90,"whatever@gmail.com",5,"PO-174"); cout<<"Testiranje svih klasa i njenih konstruktora:\n"; zap.Info(); vip.Info(); vip2.Info(); Osoba *pok[3]; pok[0]=(Zaposlenik*) &zap; //new Zaposlenik(zap); pok[1]=(VIPKlijent*) &vip; //new VIPKlijent(vip); pok[2]=(VIPKlijent*) &vip2; //new VIPKlijent(vip2); cout<<endl<<"Testiranje globalnih funkcija"<<endl<<endl; cout<<"Klijenti koji su ostvarili vecu potrosnju od: "<<z<<" su:"; cout<<"i ima ih: "<<pretragaPotrosnje(pok,3); cout<<endl<<endl<<"Ispis VIP klijenata nakon izracunatog popusta, koji su potrosili preko 50:"<<endl; pretragaVIPKlijenata(pok,3); cout<<endl<<endl<<"Svi klijenti koji sadrze "<<ab<<" u imenu ili prezimenu: "<<endl; pretragaPoImenu(pok,3); cout<<endl<<endl<<"Postavljanje mail adresa u formatu ime.prezime@firma.ba"<<endl; generisiMailAdrese(pok,3); for(int i=0; i< 3;i++) { pok[i]->Info(); } }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
w
16 hours ago | 0.09 KB
[email protected]
- idiot sending fr...
17 hours ago | 1.35 KB
Untitled
21 hours ago | 0.03 KB
Checking in availability
1 day ago | 0.66 KB
TRMP TOKEN
1 day ago | 1.56 KB
Untitled
1 day ago | 0.16 KB
my-push Script
1 day ago | 0.19 KB
Mapscan v2.0 - Archeagus Grey Hack Series, Ep...
JavaScript | 2 days ago | 9.34 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!