Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "Korisnik.h"
  3. #include "Racun.h"
  4. #include <iostream>
  5.  
  6. // konstruktor
  7. Korisnik::Korisnik() {
  8. }
  9.  
  10. Korisnik::~Korisnik() {
  11.     baza.save_data("Racuni.txt");
  12. }
  13.  
  14. // seteri
  15. void Korisnik::set_username(std::string un) {
  16.     username = un;
  17. }
  18. void Korisnik::set_password(std::string pw) {
  19.     password = pw;
  20. }
  21. void Korisnik::set_ime(std::string i) {
  22.     ime = ime;
  23. }
  24. void Korisnik::set_prezime(std::string p) {
  25.     prezime = prezime;
  26. }
  27.  
  28. // geteri
  29. std::string Korisnik::get_username() {
  30.     return username;
  31. }
  32. std::string Korisnik::get_password() {
  33.     return password;
  34. }
  35. std::string Korisnik::get_ime() {
  36.     return ime;
  37. }
  38. std::string Korisnik::get_prezime() {
  39.     return prezime;
  40. }
  41.  
  42. // funkcije
  43. bool Korisnik::login() {
  44.     std::string ime, sifra;
  45.     bool uspjeh;
  46.     std::cout << "Unesite korisnicko ime: ";
  47.     std::cin >> ime;
  48.     std::cout << "Unesite lozinku: ";
  49.     std::cin >> sifra;
  50.     uspjeh = baza.find_and_load_data("Racuni.txt", ime, sifra);
  51.     if (uspjeh) {
  52.         set_username(baza.get_un());
  53.         set_password(baza.get_pw());
  54.         set_ime(baza.get_i());
  55.         set_prezime(baza.get_p());
  56.         racun.set_broj_racuna(baza.get_br_rac());
  57.         racun.set_stanje(baza.get_st());
  58.     }
  59.     else {
  60.         std::cout << "\nUnijeli ste pogrešne podatke!\n";
  61.         system("pause");
  62.     }
  63.     return uspjeh;
  64. }
  65.  
  66. void Korisnik::podigni_novac() {
  67.     int iznos;
  68.     std::cout << "Koliko novca zelite podignuti: ";
  69.     std::cin >> iznos;
  70.     racun.set_stanje(racun.get_stanje() - iznos);
  71.     baza.set_novo_stanje(racun.get_stanje());
  72.     std::cout << "\Podigli ste " << iznos << " kuna.\n";
  73. }
  74.  
  75. void Korisnik::prikazi_stanje() {
  76.     std::cout << "Na racunu " << racun.get_broj_racuna() <<
  77.         " imate " << racun.get_stanje() << " kuna\n";
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement