Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. import java.util.LinkedList;
  2. import java.util.Scanner;
  3. class draugas{
  4. String Name;
  5. String phoneNumber;
  6. String email;
  7. String skype;
  8.  
  9. draugas (String Name, String phoneNumber, String email, String skype){
  10. this.Name = Name;
  11. this.phoneNumber = phoneNumber;
  12. this.email = email;
  13. this.skype = skype;
  14. }
  15.  
  16. void setStudentas (String a, String b, String c, String d){
  17. Name = a;
  18. phoneNumber = b;
  19. email = c;
  20. skype = d;
  21. }
  22.  
  23. String getName(){
  24. return Name;
  25. }
  26.  
  27. String getphoneNumber(){
  28. return phoneNumber;
  29. }
  30.  
  31. String getemail(){
  32. return email;
  33. }
  34.  
  35. String getskype(){
  36. return skype;
  37. }
  38.  
  39. static LinkedList<draugas> raskDr(LinkedList<draugas> list, String value, char parametras){
  40. LinkedList<draugas> tempList = new LinkedList<draugas>();
  41. for (int i = 0; i< list.size(); i++){
  42. if (parametras == 'v'){
  43. if (list.get(i).getName().equals(value)){
  44. tempList.add(list.get(i));
  45. }
  46. }
  47. else if (parametras == 't'){
  48. if (list.get(i).getphoneNumber().equals(value)){
  49. tempList.add(list.get(i));
  50. }
  51. }
  52. else if (parametras == 'e'){
  53. if (list.get(i).getemail().equals(value)){
  54. tempList.add(list.get(i));
  55. }
  56. }
  57. else if (parametras == 's'){
  58. if (list.get(i).getskype().equals(value)){
  59. tempList.add(list.get(i));
  60. }
  61. }
  62. }
  63. return tempList;
  64. }
  65. public static void main (String[] args){
  66. LinkedList<draugas> list = new LinkedList<draugas>();
  67. list.add(new draugas("Tadas", "+370441584", "Tadas@email.com", "TadasV"));
  68. list.add(new draugas("Jonas", "+370441584", "Jonas@email.com", "JonasM"));
  69. list.add(new draugas("Mantas", "+370441584", "Mantas@email.com", "MantasR"));
  70. Value f = new Value();
  71. String draugas = f.getValue("Iveskite Varda,Tel.nr,E.pasta,skype(atskirkite tarpu)");
  72. String[] tempInfo = draugas.split(" ");
  73. list.add(new draugas(tempInfo[0],tempInfo[1],tempInfo[2],tempInfo[3]));
  74. while (true){
  75.  
  76. Scanner sc=new Scanner(System.in);
  77. String command=sc.nextLine();
  78. if (command.compareTo("0")==0) break;
  79. sc=new Scanner(command).useDelimiter(" ");
  80. char parametras = sc.next().charAt(0);
  81. String value=sc.next();
  82. raskDr(list, value, parametras);
  83. }
  84. System.out.println(gettempList());
  85. }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement