import java.util.*; |
public class Main{ |
public static void main(String[] args ) { |
Scanner scan = new Scanner(System.in); |
int num, no, score, i, j; |
String name, op; |
|
num = scan.nextInt(); |
List<Student> L = new LinkedList<Student>(); |
Student s; |
for (i = 0 ; i < num; i++) { |
no = scan.nextInt(); |
name = scan.next(); |
score = scan.nextInt(); |
s = new Student(no, name, score); |
L.add(s); |
} |
num = scan.nextInt(); |
|
for (j = 0 ; j < num; j++) { |
op = scan.next(); |
if (op.equals( "add" )){ |
no = scan.nextInt(); |
name = scan.next(); |
score = scan.nextInt(); |
s = new Student(no, name, score); |
L.add(s); |
} |
else if (op.equals( "delete" )) { |
no = scan.nextInt(); |
for (i = 0 ; i < L.size(); i++) { |
if (L.get(i).getNo() == no) { |
L.remove(i); |
} |
} |
} |
else if (op.equals( "set" )) { |
no = scan.nextInt(); |
score = scan.nextInt(); |
for (i = 0 ; i < L.size(); i++) { |
if (L.get(i).getNo() == no) { |
L.get(i).setScore(score); |
} |
} |
} |
} |
|
for (i = 0 ; i < L.size(); i++) { |
System.out.println(L.get(i)); |
} |
|
|
scan.close(); |
} |
} |
class Student{ |
int no; |
String name; |
int score; |
public Student( int _no, String _name, int _score) { |
no = _no; |
name = _name; |
score = _score; |
} |
public int getNo() { |
return no; |
} |
public String getName() { |
return name; |
} |
public int getScore() { |
return score; |
} |
public void setScore( int sc) { |
score = sc; |
} |
public String toString() { |
return "no:" +no + " name:" +name + " score:" +score; |
} |
public boolean equals(Student s) { |
if ( this .no==s.getNo() && this .name.equals(s.getName()) && this .score==s.getScore()) |
return true ; |
else |
return false ; |
} |
public int hashcode() { |
int result = 17 ; |
result = 31 *result + no; |
return result; |
} |
} |