ex1)
class Person {
String name;
int age;
boolean student;
double weight;
Person(String name, int age, boolean student, double weight) {
this.name = name;
this.age = age;
if (student) {
this.student = true;
} else {
this.student = false;
}
this.weight = weight;
}
void printProfile() {
System.out.println("이름 : " + name);
System.out.println("나이 : " + age);
System.out.println("대학생인가요? : " + student);
System.out.println("몸무게 : " + weight);
}
}
public class ex1 {
public static void main(String[] args) {
Person iu = new Person("아이유", 30, true, 40.5);
iu.printProfile();
}
}
ex2)
class Person {
String name;
int age;
boolean student;
double weight;
Person(String name, int age, boolean student, double weight) {
this.name = name;
this.age = age;
if (student) {
this.student = true;
} else {
this.student = false;
}
this.weight = weight;
}
Person(String name, String age, boolean student, String weight) {
this.name = name;
this.age = Integer.parseInt(age);
if (student) {
this.student = true;
} else {
this.student = false;
}
this.weight = Double.parseDouble(weight);
}
Person(String name, int age, boolean student, String weight) {
this.name = name;
this.age = age;
if (student) {
this.student = true;
} else {
this.student = false;
}
this.weight = Double.parseDouble(weight);
}
Person(String name, String age, boolean student, double weight) {
this.name = name;
this.age = Integer.parseInt(age);
if (student) {
this.student = true;
} else {
this.student = false;
}
this.weight = weight;
}
void printProfile() {
System.out.println("이름 : " + name);
System.out.println("나이 : " + age);
System.out.println("대학생인가요? : " + student);
System.out.println("몸무게 : " + weight);
System.out.println("");
}
}
public class ex2 {
public static void main(String[] args) {
Person iu1 = new Person("아이유", 30, true, 40.5);
iu1.printProfile();
Person iu2 = new Person("아이유", 30, true, 40.5);
iu2.printProfile();
Person iu3 = new Person("아이유", 30, true, 40.5);
iu3.printProfile();
Person iu4 = new Person("아이유", 30, true, 40.5);
iu4.printProfile();
}
}
ex3)
class Calculator {
String name;
Calculator(String name){
this.name = name;}
String getOwner() {
return this.name;}
int add(int a, int b) {
return a + b;}
int minus(int a, int b) {
return a - b;}
int multiply(int a, int b) {
return a * b;}
double divide(double a, double b) {
return a / b;}
double divide(String a, String b){
return Double.parseDouble(a) / Double.parseDouble(b);}
}
public class Test {
public static void main(String[] args) {
Calculator calculator = new Calculator("제이슨");
System.out.println("이 계산기는 " + calculator.getOwner() + "의 계산기입니다.");
System.out.println("3+4는 " + calculator.add(3, 4) + "입니다.");
System.out.println("6-2는 " + calculator.minus(6, 2) + "입니다.");
System.out.println("2*9는 " + calculator.multiply(2, 9) + "입니다.");
System.out.println("9/4은 " + calculator.divide(9, 4) + "입니다.");
System.out.println("9/4은 " + calculator.divide("9", "4") + "입니다.");
}
}
ex4)
import java.util.*;
class Student {
String name = "";
int KoreanS = 0;
int EnglishS = 0;
Student(String name, int Korean, int English) {
this.name = name;
this.KoreanS = Korean;
this.EnglishS = English;}
String getName() {
return this.name;}
int getKoreanS() {
return this.KoreanS;}
int getEnglishS() {
return this.EnglishS;}
}
public class Score {
public static void main(String[] args) {
List<Student> students = new ArrayList<Student>();
students.add(new Student("제이슨", 87, 92));
students.add(new Student("레이첼", 82, 92));
students.add(new Student("리사", 92, 88));
for (int i = 0; i < students.size(); i++) {
System.out.println("이름 : " + students.get(i).getName());
System.out.println("국어 : " + students.get(i).getKoreanS());
System.out.println("영어 : " + students.get(i).getEnglishS());
}
}
}
미션 - 책 대여하기
-ing...
요 며칠 많은 생각들로 우울했다. 쓸데없는 완벽주의 성향인 사람은 무엇을 시작하기가 굉장히 어렵다. 낯설고 익숙하지 않은 이 상황들을 내 스스로 만족하고 이해할 때까지 감정소비를 하기 때문에 빨리 지치고 좌절하기 마련이다. 너무 먼 미래를 생각하기보다 하루하루 열심히 살기로 했다. 고민하고 방황하고 엄마아빠를 힘들게 하고 마음고생한 과거들이 자양분이 되기를. 예전보단 회복하는 시간이 짧아졌지만 얼마나 더 수련해야 단단한 사람이 될까. 좀 안정이 되니 화면의 코드들이 한줄한줄 눈에 들어왔다. 남은 스터디 회차들은 좀 더 나아지길 바라며...
안녕하세요 수현님! 최근에 마음 고생을 많이 하신 것 같아서 마음이 좋지 않네요🥺 수현님의 얘기를 들으니 저도 예전에 한창 취업 준비를 할 때, 완벽주의 성향으로 인해 고생도 많이하고 학습도 더뎠던 시절이 떠오르네요. 그러면서 여러가지 스트레스가 한 번에 왔는 지 부모님과 크게 싸우고 상처를 드렸던 기억이 나네요ㅠㅠ 저도 인생을 살아가면서 생각보다 꽤나 빈번하게 슬럼프가 찾아오고, 힘든 일들이 저의 의지와 상관없이 닥치게 되는 것 같더라구요... 그 순간은 정말 힘들지만 계속해서 어찌어찌 이겨내고 살아가다보니, 어느새 조금씩 단단해져가고 있는 나 자신을 발견할 수 있더라구요. 수현님도 지금의 힘든 시간들이 수현님을 더 단단하게 만들어주고 멋있는 사람으로 만들어주기를 응원하겠습니다!!!