/*import java.util.*;
class Human
{
int age;
String name;
//field
//method
void speak()
{
System.out.println("안녕, 나는 "+name+"이고, "+age+"살 이야.");
}
}
public class Main {
public static void main(String[] args) {
//Scanner in = new Scanner(System.in);
Human h1;
h1 = new Human();
//h1.age=in.nextInt();
h1.age=10;
h1.name="ywoo";
Human h2 = new Human();
h2.age=500;
h2.name="teacher";
h1.speak(); //method
h2.speak();
//System.out.println();
}
}
접근지정자
public private (클래스 내부)
public default protected private
import java.util.*;
class Rectangle {
private int ga;
int se;
String color;
Rectangle () //생성자 contructor
{
ga=10 ; se=20;
}
Rectangle (int ga, int se) //생성자 contructor
{
this.ga=ga; this.se=se;
}
Rectangle (int ga, int se, String c)
{
this(ga,se); // 자신의 다른 생성자 호출
color=c;
}
void setga(int g)
{
ga=g;
}
int getga()
{
return ga;
}
int Area() {return ga*se;}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Rectangle rect = new Rectangle(10,20);
rect.setga(in.nextInt());
rect.se=in.nextInt();
System.out.println("이 직사각형의 넓이는 "+rect.Area()+"입니다");
in.close();
}
}
*//*
import java.util.*;
class Rectangle {
int ga,se;
public Rectangle(int x, int y) {
ga=x;se=y;
}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Rectangle [] R = new Rectangle[50]; //제!!일!!중!!요!! //레퍼런스변수배열만 만들었음. 아직 객체 안만들어짐
for(int i=0;i<R.length;i++) //객체 50개 만들기
R[i]=new Rectangle(i,i);
in.close();
}
}
*/
/*
import java.util.*;
class Circle {
int radius;
Circle(int radius) {
this.radius=radius;
}
double ReturnArea() {
return radius*radius*3.14;
}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Circle [] c = new Circle[5];
for(int i=0;i<5;i++) {
c[i]=new Circle(i);
System.out.println((int)c[i].ReturnArea());
}
in.close();
}
}*/
/*
import java.util.*;
class Book {
String name,author;
Book(String name, String author) {
this.name=name;
this.author=author;
}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Book [] b = new Book[2];
for(int i=0;i<2;i++) {
System.out.print("제목 >> ");
String name=in.nextLine();
System.out.print("저자 >> ");
String author=in.nextLine();
b[i] = new Book(name,author);
}
for(int i=0;i<2;i++) {
System.out.print("("+b[i].name+", "+b[i].author+") ");
}
in.close();
}
}*/
////////////////////////////////////////////////////////////////////////
/* 1번 문제
import java.util.Scanner;
class TV {
String company;
int year,inch;
TV(String company, int year, int inch) {
this.company=company;
this.year=year;
this.inch=inch;
}
void show() {
System.out.println(company+"에서 만든 "+year+"년형 "+inch+"인치 TV");
}
}
public class Main {
public static void main(String[] args) {
TV myTV = new TV("LG",2017,32);
myTV.show();
}
}*/
/* 2번 문제
import java.util.Scanner;
class Grade {
int math,science,english;
Grade(int math, int science, int english) {
this.math=math;
this.science=science;
this.english=english;
}
int average() {
return (math+science+english)/3;
}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("수학, 과학, 영어 순으로 3개의 정수 입력>>");
int math=in.nextInt();
int science=in.nextInt();
int english=in.nextInt();
Grade me = new Grade(math,science,english);
System.out.println("평균은 "+me.average());
in.close();
}
}*/
/*
import java.util.*;
class Song {
int year;
String country,artist,title;
Song(int year,String country,String artist,String title) {
this.year=year;
this.country=country;
this.artist=artist;
this.title=title;
}
void show() {
System.out.println(year+"년 "+country+"국적의 "+artist+"가 부른 "+title);
}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("년도>> ");
int year = in.nextInt();
System.out.print("국적>> ");
String country = in.next();
System.out.print("가수>> ");
String artist = in.next();
System.out.print("제목>> ");
String title1 = in.next();
String title2 = in.next();
Song s= new Song(year,country,artist,title1+" "+title2);
s.show();
in.close();
}
}*/
/* 짜증나는 4번
import java.util.*;
class Rectangle {
int x,y,width,height;
Rectangle(int x, int y, int width, int height) {
this.x=x;
this.y=y;
this.width=width;
this.height=height;
}
int square() {
return height*width;
}
boolean contains(Rectangle a) {
if(a.x>x && a.y>y && a.width+a.x<width+x && a.height+a.y<height+y ) return true;
else return false;
}
void show() {
System.out.println("("+x+","+y+")에서 크기가 "+width+"x"+height+"인 사각형");
}
}
public class Main {
public static void main(String[] args) {
Rectangle r = new Rectangle(2,2,8,7);
Rectangle s = new Rectangle(5,5,6,6);
Rectangle t = new Rectangle(1,1,10,10);
r.show();
System.out.println("s의 면적은 "+s.square());
if(t.contains(r)) System.out.println("t는 r을 포함합니다.");
if(t.contains(s)) System.out.println("t는 s를 포함합니다.");
}
}*/
/*
import java.util.*;
class Circle {
private double x,y;
private int radius;
public Circle(double x, double y, int radius) {
this.x=x;
this.y=y;
this.radius=radius;
}
public void show() {System.out.println("("+x+","+y+")"+radius);}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Circle c [] = new Circle[3];
for(int i=0;i<c.length;i++) {
System.out.print("x, y, radius >>");
double x = in.nextDouble();
double y = in.nextDouble();
int radius = in.nextInt();
c[i]= new Circle(x,y,radius);
}
for(int i=0;i<c.length;i++) c[i].show();
in.close();
}
}*/
//이것으로 성공적으로 5번까지 마친 연우! 다음에는 어떤 위험이 도사리고 있을지... 다음편에 계속됩니다! 빠ㅏ바ㅏ빠빠빠ㅏㅏ빠바ㅏ바바빠빠ㅏㅏㅏ