-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintRows.java
More file actions
26 lines (20 loc) · 773 Bytes
/
Copy pathPrintRows.java
File metadata and controls
26 lines (20 loc) · 773 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
26
package command;
import factory.Student;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class PrintRows implements Command {
private Student student;
public PrintRows(Student student) {
this.student = student;
}
@Override
public void print(OutputStream stream) throws IOException {
DataOutputStream dataOutputStream = new DataOutputStream(stream);
dataOutputStream.writeChars(String.format("Student [%s]: ", 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.writeChar('\n');
}
}