Guest User

Untitled

a guest
May 31st, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. package fakultet.modem;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.InputStreamReader;
  5.  
  6. public class Modem implements Interfejs {
  7.  
  8. private boolean povezan;
  9. private int brzina;
  10. private String user,password;
  11.  
  12. Modem(){
  13.  
  14. user=null;
  15. password=null;
  16. brzina=0;
  17. povezan=false;
  18. }
  19. public Modem(String user,String password,int brzina,boolean povezan){
  20.  
  21. this.user=user;
  22. this.password=password;
  23. this.brzina=brzina;
  24. this.povezan=povezan;
  25. }
  26.  
  27. public void setUser(){
  28.  
  29.  
  30. try{
  31.  
  32. BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
  33. System.out.println("Unesite username: ");
  34. user=in.readLine();
  35. do{
  36. if(user.length()<6) {
  37. System.out.println("Unesite username ponovo (user>6): ");
  38. user=in.readLine();
  39. }
  40.  
  41. }
  42. while(user.length()<6);
  43. }catch(Exception E){
  44.  
  45. System.out.println("Desio se izuzetak!\n");
  46.  
  47. }
  48.  
  49. }
  50.  
  51. public void setPassword(){
  52.  
  53. try{
  54.  
  55. BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
  56. System.out.println("Unesite password: ");
  57. password=in.readLine();
  58. do{
  59. if(password.length()<6) {
  60. System.out.println("Unesite username ponovo (user>6): ");
  61. password=in.readLine();
  62. }
  63.  
  64. }
  65. while(password.length()<6);
  66. }catch(Exception E){
  67.  
  68. System.out.println("Desio se izuzetak!\n");
  69.  
  70. }
  71.  
  72.  
  73.  
  74. }
  75.  
  76. public int getBrzina() {
  77. return brzina;
  78. }
  79. public void setBrzina(int brzina) {
  80. this.brzina = brzina;
  81. }
  82. public String getPassword() {
  83. return password;
  84. }
  85. public String getUser(){
  86.  
  87. return user;
  88. }
  89.  
  90. public void poveziSe() {
  91.  
  92. this.povezan=true;
  93.  
  94. }
  95.  
  96.  
  97. public void prekinivezu() {
  98.  
  99. this.povezan=false;
  100.  
  101. }
  102.  
  103. public String toString(){
  104.  
  105. String ret;
  106. ret="Modem povezan: "+isPovezan()+"\n"+"Brzina modema: "+getBrzina()+"\n"+"Username: "+getUser()+"\n"+"Password: "+getPassword()+"\n";
  107. return ret;
  108. }
  109.  
  110. public boolean isPovezan() {
  111. return povezan;
  112. }
  113. public void setPovezan(boolean povezan) {
  114. this.povezan = povezan;
  115. }
  116. public static void main(String[] args) {
  117.  
  118.  
  119. Modem m=new Modem();
  120. m.setUser();
  121. m.setPassword();
  122. m.setBrzina(56);
  123. m.setPovezan(true);
  124. System.out.println(m);
  125. }
  126.  
  127. }
Add Comment
Please, Sign In to add comment