Ich sehe das so, dass diese Menschen wahrscheinlich schon vorher wussten, dass sie Schluss machen wollen. Sie haben den emotionalen Stress schon hinter sich oder mussten schon mal Schluss machen und können es besser ab. Natürlich kann es auch davon abhängen wie die Person selber über die Beziehung gedacht hat.
Antwort
Antwort
Hört sich danach an, als ob dein Freund mit irgendetwas unzufrieden ist. Vielleicht stört ihn etwas oder er fühlt sich gestresst.
Vielleicht frag ihn, ob ihm etwas stört. Kann sein, dass er nicht darüber sprechen will oder weiß selber nicht woher seine schlechte Laune kommt.
Wenn er sich nicht kooperativ verhält und selber initiative zeigt, die Situation zu verbessern, solltes du vielleicht nachdenken, ob du hoffen willst, dass sich seine Laune von alleine ändert oder du gehst wie du schon sagst wirklich auf Distanz oder machst Schluss.
Denk dran, auch wenn er sagt du nervst oder er weist die Schuld auf dich, dass das eigentliche Problem bei ihm liegt.
Antwort
Lecturer:
import java.io.DataInputStream;
//import java.io.DataOutputStream;
import java.io.IOException;
public class Lecturer {
private String firstName = "";
private String lastName = "";
public Lecturer() {
super();
}
public Lecturer(String firstName, String lastName) {
super();
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append(firstName);
result.append(" ");
result.append(lastName);
return result.toString();
}
public void load(DataInputStream dis) throws IOException {
//TODO: implement this
this.setFirstName(dis.readUTF());
this.setLastName(dis.readUTF());
}
}
Antwort
Date:
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Date {
private int year;
private int month;
private int day;
private int hour;
private String lectureHall = "";
private List<String> topics = new ArrayList<>();
public Date() {
super();
}
public Date(int year, int month, int day, int hour, String lectureHall) {
super();
this.year = year;
this.month = month;
this.day = day;
this.hour = hour;
this.lectureHall = lectureHall;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public String getLectureHall() {
return lectureHall;
}
public void setLectureHall(String lectureHall) {
this.lectureHall = lectureHall;
}
public List<String> getTopics() {
return topics;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append(year);
result.append("-");
result.append(month);
result.append("-");
result.append(day);
result.append(" ");
result.append(hour);
result.append(":00, ");
result.append(lectureHall);
result.append(" ");
result.append(topics);
return result.toString();
}
public void load(DataInputStream dis) throws IOException {
this.setYear(dis.readInt());
this.setMonth(dis.readInt());
this.setDay(dis.readInt());
this.setHour(dis.readInt());
this.setLectureHall(dis.readUTF());
int zahl3 = dis.readInt();
for (int k = 0; k < zahl3; k++) {
topics.add(k, dis.readUTF());
}
}
}
Antwort
LectureOMP:
import java.io.IOException;
public class LectureOMP {
public static void main(String[] args) {
try {
// task 1
Lecture omp = Lecture.load("omp.dat");
System.out.println(omp);
// task 2
//Lecture.saveText("omp.txt", omp);
//omp = Lecture.loadText("omp.txt");
//System.out.println(omp);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Antwort
Vollständige Klasse Lecture:
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
public class Lecture {
private String number = "";
private String title = "";
private String shortTitle = "";
private String semester = "";
private List<Lecturer> lecturers = new ArrayList<>();
private List<Date> schedule = new ArrayList<>();
public Lecture(String number, String title, String shortTitle, String semester) {
super();
this.number = number;
this.title = title;
this.shortTitle = shortTitle;
this.semester = semester;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getShortTitle() {
return shortTitle;
}
public void setShortTitle(String shortTitle) {
this.shortTitle = shortTitle;
}
public String getSemester() {
return semester;
}
public void setSemester(String semester) {
this.semester = semester;
}
public List<Lecturer> getLecturers() {
return lecturers;
}
public List<Date> getSchedule() {
return schedule;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append(number);
result.append(": ");
result.append(title);
result.append(" (");
result.append(shortTitle);
result.append("), ");
result.append(semester);
result.append("\n\t");
for (int i = 0; i < lecturers.size(); i++) {
if (i > 0) {
result.append(", ");
}
result.append(lecturers.get(i));
}
for (Date date : schedule) {
result.append("\n\t- ");
result.append(date);
}
result.append("\n");
return result.toString();
}
public static Lecture load(String filename) throws IOException {
Lecture result = null;
InputStream in = null;
try {
in = new FileInputStream(filename);
result = load(in);
} finally {
if (in != null) {
in.close();
}
}
return result;
}
public static Lecture load(InputStream in) throws IOException {
//TODO: implement this (task 1)
return null;
}
public static void saveText(String filename, Lecture data) throws IOException {
//TODO: implement this (task 2)
try (DataOutputStream out = new DataOutputStream (new BufferedOutputStream (new FileOutputStream(filename)))){
out.writeUTF(data.number);
out.writeUTF(data.title);
out.writeUTF(data.shortTitle);
out.writeUTF(data.semester);
int zahl = data.lecturers.size();
out.writeInt(zahl);
for (int i = 0; i < zahl; i++) {
out.writeUTF(data.lecturers.get(i).getFirstName());
out.writeUTF(data.lecturers.get(i).getLastName());
}
int zahl2 = data.schedule.size();
out.writeInt(zahl2);
for (int i = 0; i < zahl2; i++) {
out.writeInt(data.schedule.get(i).getYear());
out.writeInt(data.schedule.get(i).getMonth());
out.writeInt(data.schedule.get(i).getDay());
out.writeInt(data.schedule.get(i).getHour());
out.writeUTF(data.schedule.get(i).getLectureHall());
int zahl3 = data.schedule.get(i).getTopics().size();
for (int k = 0; k < zahl3; k++) {
out.writeUTF(data.schedule.get(i).getTopics().get(k));
}
}
}
}
public static Lecture loadText(String filename) throws IOException {
//TODO: implement this (task 2)
Lecture eins;
try (DataInputStream in = new DataInputStream (new BufferedInputStream (new FileInputStream(filename)))){
String NewNumber = in.readUTF();
String NewTitle = in.readUTF();
String NewShortTitle = in.readUTF();
String NewSemester = in.readUTF();
eins = new Lecture(NewNumber, NewTitle, NewShortTitle, NewSemester);
int zahl = in.readInt();
for (int i = 0; i < zahl; i++) {
eins.lecturers.get(i).load(in);
}
int zahl2 = in.readInt();
for (int i = 0; i < zahl2; i++) {
eins.schedule.get(i).load(in);
}
}
return eins;
}
}