Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- import java.util.Scanner;
- class draugas{
- String Name;
- String phoneNumber;
- String email;
- String skype;
- draugas (String Name, String phoneNumber, String email, String skype){
- this.Name = Name;
- this.phoneNumber = phoneNumber;
- this.email = email;
- this.skype = skype;
- }
- void setStudentas (String a, String b, String c, String d){
- Name = a;
- phoneNumber = b;
- email = c;
- skype = d;
- }
- String getName(){
- return Name;
- }
- String getphoneNumber(){
- return phoneNumber;
- }
- String getemail(){
- return email;
- }
- String getskype(){
- return skype;
- }
- static LinkedList<draugas> raskDr(LinkedList<draugas> list, String value, char parametras){
- LinkedList<draugas> tempList = new LinkedList<draugas>();
- for (int i = 0; i< list.size(); i++){
- if (parametras == 'v'){
- if (list.get(i).getName().equals(value)){
- tempList.add(list.get(i));
- }
- }
- else if (parametras == 't'){
- if (list.get(i).getphoneNumber().equals(value)){
- tempList.add(list.get(i));
- }
- }
- else if (parametras == 'e'){
- if (list.get(i).getemail().equals(value)){
- tempList.add(list.get(i));
- }
- }
- else if (parametras == 's'){
- if (list.get(i).getskype().equals(value)){
- tempList.add(list.get(i));
- }
- }
- }
- return tempList;
- }
- public static void main (String[] args){
- LinkedList<draugas> list = new LinkedList<draugas>();
- list.add(new draugas("Tadas", "+370441584", "Tadas@email.com", "TadasV"));
- list.add(new draugas("Jonas", "+370441584", "Jonas@email.com", "JonasM"));
- list.add(new draugas("Mantas", "+370441584", "Mantas@email.com", "MantasR"));
- Value f = new Value();
- String draugas = f.getValue("Iveskite Varda,Tel.nr,E.pasta,skype(atskirkite tarpu)");
- String[] tempInfo = draugas.split(" ");
- list.add(new draugas(tempInfo[0],tempInfo[1],tempInfo[2],tempInfo[3]));
- while (true){
- Scanner sc=new Scanner(System.in);
- String command=sc.nextLine();
- if (command.compareTo("0")==0) break;
- sc=new Scanner(command).useDelimiter(" ");
- char parametras = sc.next().charAt(0);
- String value=sc.next();
- raskDr(list, value, parametras);
- }
- System.out.println(gettempList());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement