-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintColumn.java
More file actions
25 lines (20 loc) · 781 Bytes
/
Copy pathPrintColumn.java
File metadata and controls
25 lines (20 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package command;
import factory.Student;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class PrintColumn implements Command {
private Student student;
public PrintColumn(Student student) {
this.student = student;
}
@Override
public void print(OutputStream stream) throws IOException {
DataOutputStream dataOutputStream = new DataOutputStream(stream);
dataOutputStream.writeChars(String.format("Student [%s]: \n", student.getName()));
for (int i = 0; i < student.getSubjectsSize(); i++) {
dataOutputStream.writeChars(String.format("mark:%d subject:%s", student.getMark(i), student.getSubject(i)));
dataOutputStream.writeByte('\n');
}
}
}