top of page

게시판 게시물

NUKUSEYO
2022년 9월 01일
In 소스 코드 제출
import javax.swing.*; import java.awt.*; import java.awt.event.*; /*class Nmain extends JDialog { private JTextField tf = new JTextField(12); private JButton ob = new JButton("Next"); public Nmain(JFrame frame, String title) { super(frame, title, true); ob.setForeground(Color.blue); setLayout(new FlowLayout()); add(tf); add(ob); setSize(200, 100); ob.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); } public String getInput() { if (tf.getText().length() == 0) return null; else return tf.getText(); } } public class Main extends JFrame { private Nmain dialog; public Main() { super("Main 예제 프레임"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bn = new JButton("다이얼로그 보이기"); dialog = new Nmain(this, "TSMD"); // 모달 디이얼로그 bn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(true); String text = dialog.getInput(); if (text == null) return; JButton btn = (JButton) e.getSource(); btn.setText(text); } }); getContentPane().add(bn); setSize(250,200);//MY NAME IS 직지,직지직지직지. setVisible(true); }*/ public class Main extends JFrame { public Main() { setTitle("옵션 팬 예제"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); setSize(500, 200); c.add(new MyPanel(), BorderLayout.NORTH); setVisible(true); } class MyPanel extends Panel { private JButton ibt = new JButton("이름"); private JTextField tf = new JTextField(10); private JButton cimb = new JButton("확인"); private JButton mess = new JButton("나가기"); public MyPanel() { setBackground(Color.lightGray); add(ibt); add(tf); add(cimb); add(mess); ibt.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String name = JOptionPane.showInputDialog("What's your name??"); if (name != null) tf.setText(name); } }); cimb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int result = JOptionPane.showConfirmDialog(null, "계속시겠습니다.", "OK!!", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.CLOSED_OPTION) tf.setText("JUST CLOSED WITHOUT SELECTION!!!"); else if (result == JOptionPane.CLOSED_OPTION) tf.setText("Y"); else tf.setText("N"); } }); mess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub JOptionPane.showMessageDialog(null, "나가쉬겠습니다.", "MMS", JOptionPane.ERROR_MESSAGE); } }); } }public static void main(String[] args) { new Main(); } }
0
0
1
NUKUSEYO
2022년 8월 25일
In 소스 코드 제출
import javax.swing.*; import java.awt.*; import java.awt.event.*; class Nmain extends JDialog { private JTextField tf = new JTextField(12); private JButton ob = new JButton("Next"); public Nmain(JFrame frame, String title) { super(frame, title, true); ob.setForeground(Color.blue); setLayout(new FlowLayout()); add(tf); add(ob); setSize(200, 100); ob.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); } public String getInput() { if(tf.getText().length() == 0) return null; else return tf.getText(); } } public class Main extends JFrame{ private Nmain dlog; public static void main(String[] args) { new Main(); } }
0
0
2
NUKUSEYO
2022년 8월 11일
In 소스 코드 제출
import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Main extends JFrame { JButton b = new JButton("NEW"); private Container contentPane; public Main() { setTitle("14_3"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); contentPane = getContentPane(); create(); //setSize(9500, 8740); setSize(400, 200); setVisible(true); } private void create() { } public static void main(String[] args) { new Main(); } } /* import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Main extends JFrame { JButton b = new JButton("NEW"); private Container contentPane; public Main() { setTitle("14_3"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); contentPane = getContentPane(); create(); //setSize(9500, 8740); setSize(400, 200); setVisible(true); b.setToolTipText("New File"); } private void create() { JToolBar tb = new JToolBar("Tool Bar"); tb.setBackground(Color.lightGray); tb.add(b); tb.addSeparator(); tb.add(new JLabel("Screen")); tb.add(new JTextField()); contentPane.add(tb); } public static void main(String[] args) { new Main(); } } */
0
0
2
NUKUSEYO
2022년 8월 04일
In 소스 코드 제출
import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Main extends JFrame { JLabel imgla = new JLabel(); public Main() { setTitle("imsiOS 2.5"); createMenu(); getContentPane().add(imgla, BorderLayout.CENTER); setSize(1550,1320); setVisible(true); } private void createMenu() { JMenuBar mb = new JMenuBar(); JMenu screenMenu = new JMenu("Screen"); JMenuItem [] menuItems = new JMenuItem[4]; String[] iTemTitle = {"Load","Hide","ReLoad","ShutDown"}; JMenu setJMenuBar(mb); mb.add(screenMenu); MenuActionListner listner = new MenuActionListner(); for(int i = 0; i < menuItems.length;i++) { menuItems[i] = new JMenuItem(); menuItems[i].addActionListner(listner); screenMenu.add(menuItem[i]); } mb.add(screenMenu); setJMenuBar(mb); } class MenuActionListner implements ActionListener { public void actionPerforomed(ActionEvent e) { String cmd = e.getActionCommand(); switch(cmd) { case "Load" : if(imgla.getIcon() != null) return; imgla.setIcon(new ImageIcon("img/testimg.png")); break; case "Hide" : imgla.setVisible(false); break; case "ReLoad" : imgla.setVisible(true); case "ShutDown" : System.exit(0); break; } } } public static void main(String[] args) { new Main(); } }
0
0
3
NUKUSEYO
2022년 7월 28일
In 소스 코드 제출
import javax.swing.*; /* import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main extends JFrame { static int num=0; Container c = getContentPane(); JPanel nort = new JPanel(); JPanel cent = new JPanel(); Font game = new Font("Gotham",Font.PLAIN,27); int o = (int) (Math.random() * 15)+1; // 기회 1~15 static int ans = (int) (Math.random() *600)+1; //정답 1-999 JLabel re = new JLabel("[System]"); JTextField g = new JTextField("", 20); JLabel la = new JLabel(); JLabel op = new JLabel("[System] Health: " + o); //기회출력 ImageIcon god = new ImageIcon("good.jpg"); ImageIcon bad = new ImageIcon("bad.jpg"); JLabel anso = new JLabel(god); JLabel ansb = new JLabel(bad); JLabel end = new JLabel("[Juldejeoak System] : Game Over!!!!!!!"); public Main() { setSize(1000, 890); setVisible(true); setTitle("너오징어 게임 1"); op.setFont(game); la.setFont(game); System.out.println(ans); setLayout(new BorderLayout()); c.add(BorderLayout.NORTH,nort); nort.add(la); nort.add(g); nort.add(op); c.add(BorderLayout.CENTER,cent); cent.setLayout(null); g.addKeyListener(new hikey()); g.setFocusable(true); g.requestFocus(); } class hikey extends KeyAdapter { public void keyPressed(KeyEvent e) { if(e.getKeyCode()!=10||o==0) return ; o--; op.setText("[System] Health: " + o); int n = Integer.parseInt(g.getText()); g.setText(""); if(o == 0) c.add(ansb); else if (n > ans) la.setText("[System] : DOWN"); else if (n < ans) la.setText("[System] : UP"); else if (n == ans) { la.setText("[System] : ANS!"); cent.removeAll(); anso.setSize(700, 700); anso.setLocation(350, 50); cent.add(anso); cent.repaint(); o=0; return ; } num++; JLabel wh = new JLabel("[System] Input : "+ n + " U/D/A : "+ la.getText()); wh.setSize(500, 100); wh.setLocation(350,20+num*50); cent.add(wh); cent.repaint(); if(o == 0) { //기회 안에 맞추지 못했을때 cent.removeAll(); end.setSize(700, 700); end.setLocation(350, 20); cent.add(end); ansb.setSize(700, 700); ansb.setLocation(350, 50); cent.add(ansb); cent.repaint(); } } } public static void main(String[] args) { new Main(); } } */ public class Main extends JFrame { public Main() { setTitle("14@1"); createMenu(); setSize(250,200); setVisible(true); } private void createMenu() { JMenuBar mb = new JMenuBar(); JMenu screenMenu = new JMenu("Screen"); screenMenu.add(new JMenuItem("Load")); screenMenu.add(new JMenuItem("Hide")); screenMenu.add(new JMenuItem("ReShow")); screenMenu.addSeparator(); screenMenu.add(new JMenuItem("Exit")); mb.add(screenMenu); mb.add(new JMenu("Edit")); mb.add(new JMenu("Sourse")); mb.add(new JMenu("Project")); mb.add(new JMenu("Run")); setJMenuBar(mb); } public static void main(String[] args) { new Main(); } }
0
0
2
NUKUSEYO
2022년 7월 10일
In 소스 코드 제출
다음 수업일 : 2022/07/14 숫자 범위 : 0 - 500,000 랜덤으로 기회:1번 숫자가 정답보다 작으면: down 크면: up 같으면 : ans 기회 내 ans가 나오면 꽃다발사진 나오지 않으면 묘비사진 게임종료후 다시 플레이 여부 묻기(TRUE/FALSE) 다시 플레이 시 맨 위로 가서 다시 FALSE일시 종료합니다. 출력 창 닫기 /*public class Main extends JFrame { JTextField uptf = new JTextField(20); JTextField dntf = new JTextField(20); public Main() { setTitle(""); setSize(500, 500); setVisible(true); Container c = getContentPane(); c.setLayout(new BorderLayout()); JPanel up = new JPanel(); JPanel ce = new JPanel(); JPanel dn = new JPanel(); up.setBackground(Color.darkGray); // 배경색 설정 c.add(up, BorderLayout.NORTH); // 컨테이너에 부착 JLabel nla = new JLabel("수식"); nla.setForeground(Color.WHITE); up.add(nla); up.add(uptf); ////////////////////////// ce.setBackground(Color.LIGHT_GRAY); c.add(ce, BorderLayout.CENTER); ce.setLayout(new GridLayout(4, 4)); for (int i = 0; i < 10; i++) { JButton u = new JButton(Integer.toString(i)); ce.add(u); } JButton del = new JButton("C/CE(AC)"); del.setForeground(Color.lightGray); ce.add(del); JButton eq = new JButton("="); eq.setForeground(Color.GREEN); ce.add(eq); JButton add = new JButton("+"); ce.add(add); JButton sub = (new JButton("-")); ce.add(sub); JButton mul = (new JButton("×")); ce.add(mul); JButton div = (new JButton("÷")); ce.add(div); //////////////////////// dn.setBackground(Color.darkGray); c.add(dn, BorderLayout.SOUTH); JLabel nnla = new JLabel("결과"); nnla.setForeground(Color.WHITE); dn.add(nnla); dn.add(dntf); // ce 패널에 있는 모든 컴포넌트 가져오기 Component btns[] = ce.getComponents(); // 모든 컴포넌트에 액션리스너 붙이기 for (int i = 0; i < btns.length; i++) ((JButton) btns[i]).addActionListener(new Act()); // 추가할것 : =눌렀을때 계산결과 출력하기 ///////////////// } class Act implements ActionListener { public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); if (b.getText().equals("=")) { cal(); } else if (b.getText().equals("C/CE(AC)")) { uptf.setText(""); } else { uptf.setText(uptf.getText() + b.getText()); } } public void cal() { String r = uptf.getText(); // r[i] -> r.charAt(i) for(int i = 0; i) if (c == '+') { dntf.setText(Integer.toString(a + b)); } if (c == '-') { dntf.setText(Integer.toString(a - b)); } if (c == '×') { dntf.setText(Integer.toString(a * b)); } if (c == '÷') { dntf.setText(Integer.toString(a / b)); } } } public static void main(String[] args) { new Main(); } } ImageIcon s = new ImageIcon("img\\rock.png"); ImageIcon v = new ImageIcon("img\\sissor2.png"); ImageIcon g = new ImageIcon("img\\paper.png"); JButton sis = new JButton(s); JButton rok = new JButton(v); JButton pap = new JButton(g); JLabel imgme = new JLabel(); JLabel imgcu = new JLabel(); JLabel gamew = new JLabel("GAME"); public Main() { setSize(1500, 1200); setVisible(true); Container c = getContentPane(); setLayout(new BorderLayout()); JPanel choice = new JPanel(); choice.setBackground(Color.DARK_GRAY); c.add(choice, BorderLayout.NORTH); JPanel game = new JPanel(); c.add(game, BorderLayout.CENTER); game.setBackground(Color.GRAY); sis.addActionListener(new Act()); rok.addActionListener(new Act()); pap.addActionListener(new Act()); choice.add(sis); choice.add(rok); choice.add(pap); JLabel gamme = new JLabel("me"); JLabel gamcu = new JLabel("cu"); gamew.setForeground(Color.GREEN); game.add(imgme); game.add(gamme); game.add(imgcu); game.add(gamcu); game.add(gamew); } class Act implements ActionListener { public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); // me 이미지 설정 if (b.equals(sis)) imgme.setIcon(s); else if (b.equals(rok)) imgme.setIcon(v); else imgme.setIcon(g); // com 이미지 설정 (랜덤) int com = (int) (Math.random() * 3); if (com == 0) imgcu.setIcon(s); else if (com == 1) imgcu.setIcon(v); else imgcu.setIcon(g); // 승부 판독 결과를 라벨에 출력 if (imgme.getIcon().equals(imgcu.getIcon())) gamew.setText("TiE"); else if (com == 0) {//com 가위 if (imgme.getIcon().equals(v)) { //나 주먹 gamew.setText("com WIN"); } else if (imgme.getIcon().equals(g)) gamew.setText("you WIN"); } else if (com == 1) {//컴 주먹 if (imgme.getIcon().equals(s)) gamew.setText("you Lose"); else if (imgme.getIcon().equals(g)) gamew.setText("you Lose"); } else if (com == 2) { if (imgme.getIcon().equals(s)) gamew.setText("com WIN"); else if (imgme.getIcon().equals(v)) gamew.setText("you "+ "WIN"); } } } public static void main(String[] args) { new Main(); } } */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main extends JFrame { }
0
0
4
NUKUSEYO
2022년 7월 03일
In 소스 코드 제출
/* import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main extends JFrame { JTextField uptf = new JTextField(20); JTextField dntf = new JTextField(20); public Main() { setTitle(""); setSize(500, 500); setVisible(true); Container c = getContentPane(); c.setLayout(new BorderLayout()); JPanel up = new JPanel(); JPanel ce = new JPanel(); JPanel dn = new JPanel(); up.setBackground(Color.darkGray); // 배경색 설정 c.add(up, BorderLayout.NORTH); // 컨테이너에 부착 JLabel nla = new JLabel("수식"); nla.setForeground(Color.WHITE); up.add(nla); up.add(uptf); ////////////////////////// ce.setBackground(Color.LIGHT_GRAY); c.add(ce, BorderLayout.CENTER); ce.setLayout(new GridLayout(4, 4)); for (int i = 0; i < 10; i++) { JButton u = new JButton(Integer.toString(i)); ce.add(u); } JButton del = new JButton("C/CE(AC)"); del.setForeground(Color.lightGray); ce.add(del); JButton eq = new JButton("="); eq.setForeground(Color.GREEN); ce.add(eq); JButton add = new JButton("+"); ce.add(add); JButton sub = (new JButton("-")); ce.add(sub); JButton mul = (new JButton("×")); ce.add(mul); JButton div = (new JButton("÷")); ce.add(div); //////////////////////// dn.setBackground(Color.darkGray); c.add(dn, BorderLayout.SOUTH); JLabel nnla = new JLabel("결과"); nnla.setForeground(Color.WHITE); dn.add(nnla); dn.add(dntf); // ce 패널에 있는 모든 컴포넌트 가져오기 Component btns[] = ce.getComponents(); // 모든 컴포넌트에 액션리스너 붙이기 for (int i = 0; i < btns.length; i++) ((JButton) btns[i]).addActionListener(new Act()); // 추가할것 : =눌렀을때 계산결과 출력하기 ///////////////// } class Act implements ActionListener { public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); if (b.getText().equals("=")) { cal(); } else if (b.getText().equals("C/CE(AC)")) { uptf.setText(""); } else { uptf.setText(uptf.getText() + b.getText()); } } public void cal() { String r = uptf.getText(); // r[i] -> r.charAt(i) for(int i = 0; i) if (c == '+') { dntf.setText(Integer.toString(a + b)); } if (c == '-') { dntf.setText(Integer.toString(a - b)); } if (c == '×') { dntf.setText(Integer.toString(a * b)); } if (c == '÷') { dntf.setText(Integer.toString(a / b)); } } } public static void main(String[] args) { new Main(); } } */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main extends JFrame { ImageIcon s = new ImageIcon("img\\rock.png"); ImageIcon v = new ImageIcon("img\\sissor2.png"); ImageIcon g = new ImageIcon("img\\paper.png"); JButton sis = new JButton(s); JButton rok = new JButton(v); JButton pap = new JButton(g); JLabel imgme = new JLabel(); JLabel imgcu = new JLabel(); public Main() { setSize(1500, 1200); setVisible(true); Container c = getContentPane(); setLayout(new BorderLayout()); JPanel choice = new JPanel(); choice.setBackground(Color.DARK_GRAY); c.add(choice, BorderLayout.NORTH); JPanel game = new JPanel(); c.add(game, BorderLayout.CENTER); game.setBackground(Color.GRAY); sis.addActionListener(new Act()); rok.addActionListener(new Act()); pap.addActionListener(new Act()); choice.add(sis); choice.add(rok); choice.add(pap); JLabel gamme = new JLabel("me"); JLabel gamcu = new JLabel("cu"); JLabel gamew = new JLabel("GAME !!"); gamew.setForeground(Color.GREEN); game.add(imgme); game.add(gamme); game.add(imgcu); game.add(gamcu); game.add(gamew); } class Act implements ActionListener { public void actionPerformed(ActionEvent e) { JButton b = (JButton)e.getSource(); if(b.equals(sis)) imgme.setIcon(s); else if(b.equals(rok)) imgme.setIcon(v); else imgme.setIcon(g); } } public static void main(String[] args) { new Main(); } }
220703 content media
0
0
2
NUKUSEYO
2022년 6월 26일
In 소스 코드 제출
import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; /*public class Main extends JFrame{ private String [] fruits = {"학생","001 - APL","002 - BAN" ,"003 - KWI","004 - MNG", "005 - PEA", "006 - PCH ", "007 - BER" , "008 - STB" , "009 - BAB","010 - BLB" }; private String [] persons = {"점수","A+(100)","A(99-91)","B+(90-81)","B(80-75)", "B-(74-60)","C(59-51)","C-(50-46)","D(46-36)","D-(35-21)","F(20-0)"}; public Main(){ setTitle("뚱띠 0110012"); setVisible(true); int i; Container c = getContentPane(); c.setLayout(new FlowLayout()); JComboBox<String> strCombo = new JComboBox<String>(fruits); c.add(strCombo); JComboBox<String> pCombo = new JComboBox<String>(); for(i = 0;i<persons.length;i++) { pCombo.addItem(persons[i]); } c.add(pCombo); setSize(300,300); } public static void main(String[] args) { new Main(); } } import javax.swing.*; import java.awt.*; public class Main extends JFrame { JLabel la = new JLabel("150"); JSlider s = new JSlider(JSlider.HORIZONTAL, 100, 200, 150); public Main() { setTitle("뚱띠 0110012"); setVisible(true); int i; Color n = new Color(0, 0, 102); Container c = getContentPane(); c.setLayout(new FlowLayout()); la.setForeground(n); s.setPaintLabels(true); s.setPaintTicks(true); s.setPaintTrack(true); s.setMinorTickSpacing(10); s.setMajorTickSpacing(20); s.setForeground(n); s.addChangeListener(new Change()); c.add(s); c.add(la); setSize(300, 300); } class Change implements ChangeListener { public void stateChanged(ChangeEvent e) { int h = s.getValue(); la.setText(Integer.toString(h)); } } public static void main(String[] args) { new Main(); } }*/ import java.util.*; import javax.swing.*; import java.awt.*; public class Main extends JFrame { JTextField uptf = new JTextField(20); public Main() { setTitle("계산기 0.5버전"); setSize(500, 500); setVisible(true); Container c = getContentPane(); c.setLayout(new BorderLayout()); JPanel up = new JPanel(); JPanel ce = new JPanel(); JPanel dn = new JPanel(); up.setBackground(Color.darkGray); // 배경색 설정 c.add(up, BorderLayout.NORTH); // 컨테이너에 부착 JLabel nla = new JLabel("수식"); nla.setForeground(Color.WHITE); up.add(nla); up.add(uptf); ////////////////////////// ce.setBackground(Color.LIGHT_GRAY); c.add(ce, BorderLayout.CENTER); ce.setLayout(new GridLayout(4, 4)); for (int i = 0; i < 10; i++) { JButton u=new JButton(Integer.toString(i)); ce.add(u); u.addActionListener(new Act()); } JButton ob = new JButton("C/CE(AC)"); ob.setForeground(Color.lightGray); ce.add(ob); JButton tb = new JButton("Cal"); tb.setForeground(Color.GREEN); ce.add(tb); JButton hb = new JButton("+"); ob.setForeground(Color.RED); hb.addActionListener(new Act()); ce.add(hb); JButton fb = (new JButton("-")); fb.addActionListener(new Act()); fb.setForeground(Color.YELLOW); ce.add(fb); ce.add(new JButton("×")); ce.add(new JButton("÷")); //////////////////////// dn.setBackground(Color.darkGray); c.add(dn, BorderLayout.SOUTH); JLabel nnla = new JLabel("결과"); nnla.setForeground(Color.WHITE); dn.add(nnla); dn.add(new JTextField(20)); //다음시간에 추가할것 : 곱하기,나누기버튼, cal눌렀을때 계산결과 출력하기 ///////////////// } class Act implements ActionListener { public void actionPerformed(ActionEvent e) { JButton b = (JButton)e.getSource(); uptf.setText(uptf.getText()+b.getText()); } } public static void main(String[] args) { new Main(); } }
0
0
2
NUKUSEYO
2022년 6월 19일
In 소스 코드 제출
import java.awt.*; import java.awt.event.*; import javax.swing.*; /*public class Main extends JFrame { JLabel la = new JLabel("러부 잡바"); Main(){ setSize(300,280); setVisible(true); Container c = getContentPane(); setLayout(new FlowLayout()); c.add(la); la.addMouseListener(new MyMouseListner()); } class MyMouseListner extends MouseAdapter { public void mouseEntered(MouseEvent e) { la.setText("JAVA"); } public void mouseExited(MouseEvent e) { la.setText("러부 잡바"); } } public static void main(String[] args) { new Main(); } } public class Main extends JFrame { JLabel la = new JLabel("Love Java"); Main(){ setSize(680,630); setVisible(true); Container c = getContentPane(); setLayout(new FlowLayout()); c.add(la); la.addKeyListener(new hiKey()); la.setFocusable(true); la.requestFocus(); } class hiKey extends KeyAdapter { public void keyPressed(KeyEvent e) { System.out.println("OK"); int keyCode = e.getKeyCode(); if(keyCode == KeyEvent.VK_LEFT) { if(la.getText().equals("avaJ evoL")) { la.setText("Love Java"); } else { la.setText("avaJ evoL"); } } } } public static void main(String[] args) { new Main(); } } public class Main extends JFrame { JLabel la = new JLabel("C"); Main(){ setSize(600,600); setVisible(true); Container c = getContentPane(); setLayout(null); c.add(la); la.setLocation(100, 100); la.setSize(60, 60); la.addMouseListener(new hiMouse()) } class hiMouse extends MouseAdapter { public void mouseClicked(MouseEvent e) { int x = (int)(Math.random()*500)+ 40; int y = (int)(Math.random()*500)+ 40; la.setLocation(x, y); } } public static void main(String[] args) { new Main(); } } public class Main extends JFrame { JLabel la = new JLabel("hiJAVA"); Main(){ setSize(500,450); setVisible(true); Container c = getContentPane(); setLayout(new FlowLayout()); c.add(la); la.addKeyListener(new hiKey()); } class hiMouse extends KeyAdapter{ public void mouseWheelMoved(MouseWheelEvent e) { int n = e.getWheelRotation(); Font f = la.getFont(); int s = f.getSize(); } } public static void main(String[] args) { new Main(); } public class Main extends JFrame { JLabel nums[] = new JLabel[3]; JLabel la= new JLabel("시작합니다."); Main(){ setSize(500,450); setVisible(true); Container c = getContentPane(); JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); setLayout(new BorderLayout()); p1.setLayout(null); p2.setLayout(null); la.setFont(new Font("고딕",Font.BOLD,45)); la.setSize(55,55); la.setLocation(170, 170); for(int i=0;i<3;i++) { nums[i] = new JLabel("0",SwingConstants.CENTER); p1.add(nums[i]); nums[i].setSize(75,75); nums[i].setLocation(170*i+50, 150); nums[i].setBackground(Color.WHITE); nums[i].setForeground(Color.red); nums[i].setFont(new Font("Javanese Text",Font.BOLD,60)); nums[i].setOpaque(true); } c.add(p1,BorderLayout.CENTER); c.add(la,BorderLayout.SOUTH); c.addKeyListener(new hiKey()); c.setFocusable(true); c.requestFocus(); } class hiKey extends KeyAdapter{ public void keyPressed(KeyEvent e) { if(e.getKeyChar()=='\n') { for(int i=0; i<3; i++){ int x = (int)(Math.random()*10); nums[i].setText(Integer.toString(x)); } if(nums[0].getText().equals(nums[1].getText()) && nums[1].getText().equals(nums[2].getText())) { la.setText("SUC-SEE-SE"); } else { la.setText("a-sheep-zi-man X"); } } } } public static void main(String[] args) { new Main(); */ public class Main extends JFrame { private JCheckBox[] fruits = new JCheckBox[3]; private String[] names = { "사과", "배", "체리" }; private JLabel sumLabel; Main() { setTitle("체에 1105 체쿠체쿠 Box..."); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new JLabel("사과 10c(1c=10원),배 10c,체리 2000c")); hiItem hiItem = new hiItem(); for(int i = 0; i<fruits.length;i++) { fruits[i] = new JCheckBox(names[i]); fruits[i].setBorderPainted(true); c.add(fruits[i]); fruits[i].addItemListener(hiItem); } sumLabel = new JLabel("현재 0c"); c.add(sumLabel); setSize(250,200); setVisible(true); } class hiItem implements ItemListener { private int sum = 0; public void itemStateChanged(ItemEvent e) { if(e.getStateChange()==ItemEvent.SELECTED) { if(e.getItem()==fruits[0]) sum += 10; else if(e.getItem()==fruits[1]) sum += 50; else sum += 2000; } else { if(e.getItem()==fruits[0]) sum -= 10; else if(e.getItem()==fruits[1]) sum -= 50; else sum-= 2000; } sumLabel.setText("현재 "+ sum + "c 입니다."); } } public static void main(String[] args) { new Main(); } }
0
0
2
NUKUSEYO
2022년 6월 12일
In 소스 코드 제출
import java.awt.*; import java.awt.event.*; import javax.swing.*; /*public class Main extends JFrame { JLabel la = new JLabel("러부 잡바"); Main(){ setSize(300,280); setVisible(true); Container c = getContentPane(); setLayout(new FlowLayout()); c.add(la); la.addMouseListener(new MyMouseListner()); } class MyMouseListner extends MouseAdapter { public void mouseEntered(MouseEvent e) { la.setText("JAVA"); } public void mouseExited(MouseEvent e) { la.setText("러부 잡바"); } } public static void main(String[] args) { new Main(); } } public class Main extends JFrame { JLabel la = new JLabel("Love Java"); Main(){ setSize(680,630); setVisible(true); Container c = getContentPane(); setLayout(new FlowLayout()); c.add(la); la.addKeyListener(new hiKey()); la.setFocusable(true); la.requestFocus(); } class hiKey extends KeyAdapter { public void keyPressed(KeyEvent e) { System.out.println("OK"); int keyCode = e.getKeyCode(); if(keyCode == KeyEvent.VK_LEFT) { if(la.getText().equals("avaJ evoL")) { la.setText("Love Java"); } else { la.setText("avaJ evoL"); } } } } public static void main(String[] args) { new Main(); } } public class Main extends JFrame { JLabel la = new JLabel("C"); Main(){ setSize(600,600); setVisible(true); Container c = getContentPane(); setLayout(null); c.add(la); la.setLocation(100, 100); la.setSize(60, 60); la.addMouseListener(new hiMouse()) } class hiMouse extends MouseAdapter { public void mouseClicked(MouseEvent e) { int x = (int)(Math.random()*500)+ 40; int y = (int)(Math.random()*500)+ 40; la.setLocation(x, y); } } public static void main(String[] args) { new Main(); } }*/ public class Main extends JFrame { JLabel la = new JLabel("hiJAVA"); Main(){ setSize(500,450); setVisible(true); Container c = getContentPane(); setLayout(new FlowLayout()); c.add(la); la.addMouseWheelListener(new hiMouse()); } class hiMouse implements MouseWheelListener { public void mouseWheelMoved(MouseWheelEvent e) { int n = e.getWheelRotation(); if(n < 0) { System.out.println("UP"); } else { System.out.println("DN"); } } } public static void main(String[] args) { new Main(); } }
220612 content media
0
0
1
NUKUSEYO
2022년 6월 05일
In 소스 코드 제출
/*public class Main extends JFrame{ public Main() { setTitle("8번문제 533p"); setSize(700,600); setVisible(true); Container c = getContentPane(); c.setLayout(new BorderLayout()); JPanel up = new JPanel(); JPanel gv = new JPanel(); JPanel dn = new JPanel(); c.add(up,BorderLayout.NORTH); c.add(gv,BorderLayout.CENTER); c.add(dn,BorderLayout.SOUTH); up.setBackground(Color.LIGHT_GRAY); up.add(new JButton("오푼")); up.add(new JButton("클루즈")); up.add(new JButton("아우트")); gv.setBackground(Color.GRAY); gv.setLayout(null); for(int i = 0;i < 10;i++) { JLabel l = new JLabel("*"); int x = (int)(Math.random()*200) + 30; int y = (int)(Math.random()*240) + 20; l.setLocation(x, y); l.setSize(15, 15); l.setForeground(Color.GREEN); gv.add(l); } dn.setLayout(new FlowLayout()); //dn.setBackground(Color.WHITE); dn.add(new JButton("워든 인푿")); JTextField j = new JTextField(50); dn.add(j); } public static void main(String[] args) { new Main(); } }*/ /* public class Main extends JFrame { public Main() { setTitle("10단원-실습 01 이베트 리씨너"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); JButton btn = new JButton("Atsion"); btn.addActionListener(new MyActionListener()); c.add(btn); setSize(350,150); setVisible(true); } class MyActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { JButton b = (JButton)e.getSource(); if(b.getText().equals("Atsion")) b.setText("앧션"); else b.setText("Atsion"); } } public static void main(String[] args) { new Main(); } } 20220605 */ import java.awt.*; import java.awt.event.*; import javax.swing.*; //import java.util.Random; /*public class Main extends JFrame { private JLabel la = new JLabel("Hello"); public Main() { setTitle("blank"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(null); c.addMouseListener(new MyMouseListener()); la.setSize(50, 20); la.setLocation(30, 30); c.add(la); setSize(250, 250); setVisible(true); } class MyMouseListener implements MouseListener { public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); la.setLocation(x, y); } public void mouseReleased(MouseEvent e) { } public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } } public static void main(String[] args) { new Main(); } }*/ // MIS 001 /* public class Main extends JFrame { private JLabel la = new JLabel("Hello"); Color [] colors = {Color.black, Color.BLUE , Color.green, Color.DARK_GRAY , Color.CYAN , Color.red , Color.MAGENTA , Color.gray , Color.lightGray,Color.orange,Color.pink,Color.YELLOW}; public Main() { setTitle("blank"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(null); c.addMouseListener(new MyMouseListener()); la.setSize(50, 20); la.setLocation(30, 30); c.add(la); setSize(250, 250); setVisible(true); } //인터페이스를 implements 하는 경우 모든 메소드를 구현 해야함!! // 그래서 대신 필요한 메소드만 구현하려면 어댑터 클래스 extends class MyMouseListener extends MouseAdapter{ public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); la.setLocation(x, y); int num = (int)(Math.random()*colors.length); la.setForeground(colors[num]); } } class MyMouseListener implements MouseListener { public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); la.setLocation(x, y); // 1. Math.random() -> 0이상 1 미만의 랜덤 실수 // 2. Math.random()*10 -> 0이상 10미만의 랜덤 실수 // 3. (int)(Math.random()*10) -> 0이상 10미만의 랜덤 정수 // 4. (int)(Math.random()*10)+5 -> 5이상 15미만의 랜덤 정수 int num = (int)(Math.random()*colors.length); la.setForeground(colors[num]); } public void mouseReleased(MouseEvent e) { } public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { Container c = getContentPane(); c.setBackground(Color.BLUE); } public void mouseExited(MouseEvent e) { Container c = getContentPane(); c.setBackground(Color.RED); } } public static void main(String[] args) { new Main(); } } public class Main extends JFrame { private JLabel lao = new JLabel("getKeyCode()"); private JLabel lat = new JLabel("getKeyChar()"); private JLabel lah = new JLabel("getKeyText()"); public Main() { setTitle("blank"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(lao); c.add(lat); c.add(lah); c.addKeyListener(new MyKeyListener()); setSize(300, 150); setVisible(true); c.setFocusable(true); c.requestFocus(); } //인터페이스를 implements 하는 경우 모든 메소드를 구현 해야함!! // 그래서 대신 필요한 메소드만 구현하려면 어댑터 클래스 extends class MyKeyListener extends KeyAdapter{ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); char keyChar = e.getKeyChar(); lao.setText(Integer.toString(keyCode)); lat.setText(Character.toString(keyChar)); lah.setText(KeyEvent.getKeyText(keyCode)); if(keyCode==112) { Container c = getContentPane(); c.setBackground(Color.GREEN); } else if(keyCode == 53) { Container c = getContentPane(); c.setBackground(Color.YELLOW); } } } public static void main(String[] args) { new Main(); } }*/ public class Main extends JFrame { private JLabel la = new JLabel("Hello"); public Main() { setTitle("blank"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(null); c.add(la); la.setLocation(50, 50); la.setSize(100,20); c.addKeyListener(new MyKeyListener()); setSize(300, 300); setVisible(true); c.setFocusable(true); c.requestFocus(); } //인터페이스를 implements 하는 경우 모든 메소드를 구현 해야함!! // 그래서 대신 필요한 메소드만 구현하려면 어댑터 클래스 extends class MyKeyListener extends KeyAdapter{ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); char keyChar = e.getKeyChar(); int x = la.getX(); int y = la.getY(); if(keyCode==38 && y!=0 ) { la.setLocation(x, y-10); } else if(keyChar == KeyEvent.VK_LEFT && x!=0) { la.setLocation(x-10, y); } else if(keyCode == 40 && y!=300) { la.setLocation(x,y+10); } else if (keyCode == 39 && x!= 300) { la.setLocation(x+10, y); } } } public static void main(String[] args) { new Main(); } }
220605 content media
0
0
5
NUKUSEYO
2022년 5월 22일
In 소스 코드 제출
import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /*public class Main extends JFrame{ public Main() { setTitle("8번문제 533p"); setSize(700,600); setVisible(true); Container c = getContentPane(); c.setLayout(new BorderLayout()); JPanel up = new JPanel(); JPanel gv = new JPanel(); JPanel dn = new JPanel(); c.add(up,BorderLayout.NORTH); c.add(gv,BorderLayout.CENTER); c.add(dn,BorderLayout.SOUTH); up.setBackground(Color.LIGHT_GRAY); up.add(new JButton("오푼")); up.add(new JButton("클루즈")); up.add(new JButton("아우트")); gv.setBackground(Color.GRAY); gv.setLayout(null); for(int i = 0;i < 10;i++) { JLabel l = new JLabel("*"); int x = (int)(Math.random()*200) + 30; int y = (int)(Math.random()*240) + 20; l.setLocation(x, y); l.setSize(15, 15); l.setForeground(Color.GREEN); gv.add(l); } dn.setLayout(new FlowLayout()); //dn.setBackground(Color.WHITE); dn.add(new JButton("워든 인푿")); JTextField j = new JTextField(50); dn.add(j); } public static void main(String[] args) { new Main(); } }*/ public class Main extends JFrame { public Main() { setTitle("10단원-실습 01 이베트 리씨너"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); JButton btn = new JButton("Atsion"); btn.addActionListener(new MyActionListener()); c.add(btn); setSize(350,150); setVisible(true); } public static void main(String[] args) { new Main(); } } class MyActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { JButton b = (JButton)e.getSource(); if(b.getText().equals("Atsion")) b.setText("앧션"); else b.setText("Atsion"); } }
0
0
3
NUKUSEYO
2022년 5월 15일
In 소스 코드 제출
홀리몰리 내일 월요일 //import javax.swing.*; //import java.awt.*; // // //public class Main extends JFrame{ // public Main(){ // setTitle("Ten Color Buttons Frame"); // setSize(700,400); // setVisible(true); // Container c = getContentPane(); // //c.setBackground(Color.WHITE); // c.setLayout(new GridLayout()); // //정수를 문자열로 Integer.toString(i), String.valueOf(i) // //실수를 문자열로 Double.toString(i) // //문자열을 숫자로 "123" -> 123 // // for(int i=0;i<10;i++) // { // JButton b = new JButton(Integer.toString(i)); // b.setSize(200,400); // // if(i==0) b.setBackground(Color.RED); // if(i==1) b.setBackground(Color.ORANGE); // if(i==2) b.setBackground(Color.YELLOW); // if(i==3) b.setBackground(Color.GREEN); // if(i==4) b.setBackground(Color.cyan); // if(i==5) b.setBackground(Color.BLUE); // if(i==6) b.setBackground(Color.PINK); // if(i==7) b.setBackground(Color.MAGENTA); // if(i==9) b.setBackground(Color.LIGHT_GRAY); // if(i==8) b.setBackground(Color.darkGray); // // c.add(b); // } // } // public static void main(String[] args) { // new Main(); // System.out.println("1은 도 \n 2는 "); // } //} // // // /* import java.util.*; import javax.swing.*; import java.awt.*; public class Main extends JFrame{ public Main(){ setTitle("Ten Color Buttons Frame"); setSize(500,500); setVisible(true); Container c = getContentPane(); c.setLayout(null); for(int i=0;i<10;i++) { //JButton b = new JButton(Integer.toString(i)); JLabel la = new JLabel(Integer.toString(i)); //Math.random() 0이상 1 미만 실수 리턴 int x = (int)(Math.random()*450) +1; // 1 이상 400 이하 정수 int y = (int)(Math.random()*450) +1; // 1 이상 400 이하 정수 System.out.println(x+","+y); //la.setForeground(Color.red); //글자색 la.setBackground(Color.green); la.setOpaque(true); la.setLocation(x, y); la.setSize(10,10); c.add(la); } } public static void main(String[] args) { new Main(); System.out.println("1은 도 \n 2는 "); } } */ import java.util.*; import javax.swing.*; import sun.jvm.hotspot.types.JBooleanField; import java.awt.*; public class Main extends JFrame{ public Main(){ setTitle("계산기 0.5버전"); setSize(500,500); setVisible(true); Container c = getContentPane(); c.setLayout(new BorderLayout()); JPanel up = new JPanel(); JPanel ce = new JPanel(); JPanel dn = new JPanel(); up.setBackground(Color.darkGray); //배경색 설정 c.add(up,BorderLayout.NORTH); //컨테이너에 부착 JLabel nla = new JLabel("수식"); nla.setForeground(Color.WHITE); up.add(nla); up.add(new JTextField(20)); ////////////////////////// ce.setBackground(Color.LIGHT_GRAY); c.add(ce,BorderLayout.CENTER); ce.setLayout(new GridLayout(4,4)); for(int i=0;i<10;i++) { ce.add(new JButton(Integer.toString(i))); } JButton ob = new JButton("C/CE(AC)"); ob.setForeground(Color.lightGray); ce.add(ob); JButton tb = new JButton("Cal"); tb.setForeground(Color.GREEN); ce.add(tb); JButton hb = new JButton("+"); ob.setForeground(Color.RED); ce.add(hb); JButton fb = (new JButton("-")); fb.setForeground(Color.YELLOW); ce.add(fb); ce.add(new JButton("×")); ce.add(new JButton("÷")); //////////////////////// dn.setBackground(Color.darkGray); c.add(dn,BorderLayout.SOUTH); JLabel nnla = new JLabel("결과"); nnla.setForeground(Color.WHITE); dn.add(new JTextField(20)); ///////////////// } public static void main(String[] args) { new Main(); } }
ㅎㅇ content media
0
0
3
NUKUSEYO
2022년 4월 24일
In 소스 코드 제출
220424 /* import java.util.*; abstract class Shape { private Shape next; public Shape() { next = null ;} public void setNext(Shape obj) { next = obj; } // 링크 연결 public Shape getNext() { return next; } public abstract void draw(); // 추상 메소드 } class Line extends Shape { public void draw() { System.out.println("Line(선)"); } } class Rect extends Shape { public void draw() { System.out.println("Rectangle(직사각형)"); } } class Circle extends Shape { public void draw() { System.out.println("Circle(원)"); } } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("그래픽 에디터 Beauty 3.0을(를) 실행합니다."); Shape s= new Line(); while(true) { System.out.println("삽입은 1번, 삭제는 2번, 모두보기는 3번, 프로그램을 종료하려면 0번을 눌러주십시오."); int maininput = sc.nextInt(); Shape s1=s; if(maininput == 1) { while(s1.getNext()!=null){ s1=s1.getNext(); } System.out.println("Line(줄)은(는) 1번, Rect(직사각형)은(는) 2번, Circle(원)은(는) 3번을 눌러주십시오."); int shapeinput = sc.nextInt(); if(shapeinput == 1) { s1.setNext(new Line()); } else if(shapeinput == 2){ s1.setNext(new Rect()); } else if(shapeinput == 3){ s1.setNext(new Circle()); } else{ System.out.println("오류로 Beauty 3.0을 종료합니다!!"); return ; } } else if(maininput == 2) { } else if(maininput == 3) { while(true){ s1=s1.getNext(); if(s1==null) break; s1.draw(); } } else if(maininput == 0) { System.out.println("0번을 입력하셨습니다. \n프로세스 차단으로 인해 Beauty 3.0을 종료합니다"); return ; } } } } */ interface PhoneInterface { final int TIMEOUT = 1000000; void seanCall(); void resivecall(); default void printLogo() { System.out.println("** Phone **"); System.out.println("무언가 웃기고 이상한 OS 4.0"); } } interface MobilePhoneInterface extends PhoneInterface { void sendSMS(); void reciveSMS(); } interface MP3Interface { public void play(); public void stop(); } class PDA{ public int calculate(int x, int y) { return x + y; } } class SmartPhone extends PDA implements MobilePhoneInterface, MP3Interface { public void sendCall() { System.out.println("따르릉 따르릉 입니다."); } public void recievecall() { System.out.println("전화 이가 왔다."); } public void sendSMS() { System.out.println("문자가 왔어요."); } public void play() { System.out.println("음악 을를 연주합니다."); } public void stop() { System.out.println("음악 을를 중단합니다."); } public void sch() { System.out.println("일정 을를 관리합니다."); } } public class Main { public static void main(String[] args) { SmartPhone phone = new SmartPhone(); phone.printLogo(); phone.sendCall(); phone.play(); System.out.println("3 더하귀 5는 " + phone.calculate(3, 5)); phone.sch(); } }
흐아아아아아악!!!!!333333333 content media
0
0
2
NUKUSEYO
2022년 4월 17일
In 소스 코드 제출
220417 code(java 319p 10번) import java.util.*; abstract class Pairmap { protected String keyArray []; protected String valueArray []; abstract String get(String key); abstract void put(String key, String value); abstract String delete(String key); abstract int length(); } class Dictionary extends Pairmap { int len; public Dictionary(int n){ keyArray = new String[n]; valueArray = new String[n]; len=0; } String get(String key) { for(int i = 0;i <len ; i++) { if(keyArray[i].equals(key)) return valueArray[i]; } return null; } void put(String key, String value){ keyArray[len]=key; valueArray[len] = value; len++; } int length() { return keyArray.length; } String delete(String key) { String delvalue = null; for(int i = 0;i <len; i++) { if(keyArray[i].equals(key)) { keyArray[i]=""; delvalue=valueArray[i]; valueArray[i]=""; } } return delvalue; } } public class Main { public static void main(String[] args) { Dictionary dic = new Dictionary(10); dic.put("황기태" , "JAVA 15"); dic.put("이재문", "PYTHON 3.9"); dic.put("이재문","C++17" ); System.out.println("이재문의 값은 " + dic.get("이재문")); System.out.println("황기태의 값은 " + dic.get("황기태")); dic.delete("황기태"); System.out.println("황기태의 값은 " + dic.get("황기태")); } }
님들 ㅎㅇㅎㅇ content media
0
0
4
NUKUSEYO
2022년 4월 10일
In 소스 코드 제출
2022.04.10. import java.util.*; /*class Point { private int x,y; public Point(int x, int y){ this.x = x; this.y = y; } public int getX() { return x; } public int getY() { return y; } protected void move(int x , int y) { this.x = x; this.y = y;} } /*class Point3D extends Point { private int z; public Point3D(int x, int y, int z) { super(x,y); this.z = z; } public void moveup() { z--; } public void movedown( ) { z++; } public void move(int x,int y, int z) { move(x,y); this.z = z;- } public String toString() { return "(" + getX() + "," + getY() +"," + z + ")의 점"; } } */ /* class Student extends Person{ void speak() { System.out.println("저는 학생입니다."); } } */ abstract class Converter { abstract protected double convert(double src); abstract protected String getSrcString(); abstract protected String getDestString(); protected double ratio; //비율 public void run() { Scanner sc = new Scanner(System.in); System.out.println(getSrcString() + "을 " + getDestString() + "로 바꿉니다."); System.out.print(getSrcString() + "을 입력하세요>>"); double val = sc.nextDouble(); double res = convert(val); System.out.println("변환 결과는 : " + res + getDestString() + "입니다."); sc.close(); } } class Won2Dollor extends Converter{ public Won2Dollor(double ratio) { this.ratio=ratio; } protected double convert(double src) { return src/ratio; } protected String getSrcString() { return "원"; } protected String getDestString() { return "달러"; } } public class Main { public static void main(String[] args) { //Person p = new Person(); //추상클래스 객ㅊㅔ 만들 수 없다. Won2Dollor toDollor = new Won2Dollor(1200); toDollor.run(); } }
0
1
5
NUKUSEYO
2022년 4월 03일
In 소스 코드 제출
/*import java.util.*; public void show() //메소드 오버라이딩 (재정의) { super.show(); System.out.println(color); } } class TV { private int size; public TV(int size) {this.size = size;} int getSize( ) { return size;} } class ColorTV extends TV { private int color; public ColorTV(int size,int color) { super(size); this.color = color; } public void printProperty(){ System.out.print(getSize()+"인치" + color + "컬러"); } } class IPTV extends ColorTV { private String ip; public IPTV(String ip, int size, int color) { super(size,color); this.ip = ip; } public void printProperty() { System.out.print("나의 IPTV는" + ip + "주소의 "); super.printProperty(); } } class Main { public static void main(String[] args) { IPTV iptv = new IPTV("255.255.255.255", 2147483647 , 2147483647); iptv.printProperty(); } } /* class onepen { int amount; //남은 양 private int getAmount() { return amount; } public void setAmount(int amount) { this.amount = amount; } } class SharpPencil extends onepen { private int width; } class BallPen extends onepen { private String color; //색 public String getColor() { return color; } public void setColor(String color) { this.color = color; } } class FountainPen extends BallPen { public void refill(int n) {amount = n;} } */ class Point { private int x,y; public Point(int x, int y){ this.x = x; this.y = y; } public int getX() { return x; } public int getY() { return y; } protected void move(int x , int y) { this.x = x; this.y = y;} } class ColorPoint extends Point { private String color; public ColorPoint(int x, int y, String color){ super(x,y); this.color = color; } public void setXY(int x , int y) { move(x,y); } public void setColor(String color) { this.color = color; } public String toString() { return color + "색의 (" + getX() + "," + getY() + ")의 점"; } } public class Main { public static void main(String[] args) { ColorPoint cp = new ColorPoint(5,5,"YELLOW"); cp.setXY(10,20); cp.setColor("RED"); String str = cp.toString(); System.out.println(str + "입니다."); } }
0
0
4
NUKUSEYO
2022년 3월 20일
In 소스 코드 제출
//상속 /* import java.util.*; class Person{ protected int age; // protected 상속받은 클래스에서만 접근 가능 String name; public void setAge(int age) { this.age = age; } public int getAge() { return age; } public void speak() { //System.out.println("저는 사람입니다!"); } } class Student extends Person{ //Student 클래스는 Person클래스를 상속받는다. //Person 클래스를 연장해서 만든다. int grade; public void speak() { //메소드 오버라이딩 - 메소드 재정의 덮어쓰기 System.out.println("저는 학생이예요ㅠㅠ 숙제하기 싫어요ㅠㅠ"); } } class Teacher extends Person{ String sub; public void speak(){ System.out.println("그럼 집에 가세용"); } } class Main{ public static void main(String[] args) { Student s = new Student(); Teacher t = new Teacher(); s.setAge(10); t.setAge(50); s.speak(); t.speak(); } } import java.util.*; // 수퍼클래스 - 서브클래스 super - sub // 부모클래스 - 자식클래스 class Cult { int a,b; void setValue(int a,int b) { this.a =a; this.b = b; } int calculate() { return a; } } class Sum extends Cult{ int calculate() { return a+b; } } class Min extends Cult{ int calculate() { return a-b; } } class Mul extends Cult{ int calculate() { return a*b; } } class Div extends Cult{ int calculate() { return a/b; } } class Drt extends Cult { int calculate() { return a%b; } } public class Main{ public static void main(String[] args) { int a,b; char c; Scanner sc = new Scanner(System.in); a = sc.nextInt(); b = sc.nextInt(); c = sc.next().charAt(0); Cult s = null; if (c == '+') s = new Sum(); else if(c == '-') s = new Min(); else if(c == '*') s = new Mul(); else if(c == '/') s = new Div(); else if(c == '%') s = new Drt(); s.setValue(a, b); System.out.println(s.calculate()); } } */ class Point { private int x,y; public void set(int x,int y) { this.x = x; this.y = y; } public void showPoint () { System.out.println("(" + x + "," + y + ")"); } } class ColorPoint extends Point { private String color; public void setColor(String color) { this.color = color; } public void showColorPoint() { System.out.print(color); showPoint(); } } public class Main { public static void main(String[] args) { Point p = new Point(); p.set(1,2); p.showPoint(); ColorPoint cp = new ColorPoint(); cp.set(3, 4); cp.setColor("red"); cp.showColorPoint(); }
0
0
8
NUKUSEYO
2022년 3월 06일
In 소스 코드 제출
/* import java.util.*; class Circle { int radius; String name; public Circle() { //생성자 radius=1; name=""; } public Circle(int r, String n) { radius = r; name = n; } public double getArea( ) { //메소드 return 3.141592653585*radius*radius; } } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Circle pizza = new Circle(10, "자바피자"); double area = pizza.getArea(); System.out.println(pizza.name + "의 면적은 " + area); Circle donut = new Circle(); donut.name = "도넛피자"; area = donut.getArea(); System.out.println(donut.name + "의 면적은 " + area); } } import java.util.*; class Song { String title, artist, country; int year; public Song() { //기본생성자 title = "No title"; year = 2000; country = "No info of Location"; artist = "No Name"; } public Song(String title, String country,int year, String artist) //초기화용 생성자 { this.title=title; this.country = country; this.year = year; this.artist = artist; } public void show() { System.out.println(year + "년, " + country + "의 " + artist + "가 부른 " + title); } } public class Main { public static void main(String[] args) { int arr[] = new int[50]; //자료형 배열 arr[0]=5; Song sarr[] = new Song[50]; //1. 객체 배열 for(int i=0;i<sarr.length;i++) sarr[i]=new Song(); System.out.println(sarr[0].artist); //Song so = new Song("Dancing Queen", "스웨덴",1978, "아바"); //so.show(); } } */ //객체 배열 만들기 예제 4-6 import java.util.*; class Circle { int radius; public Circle(int r) { radius = r; } public double getArea( ) { //메소드 return 3.141592653585*radius*radius; } } public class Main { public static void main(String[] args) { Circle [] c; c = new Circle[5]; for(int i = 0;i<c.length;i++) { c[i] = new Circle(i); } for(int i = 0;i<c.length;i++) { System.out.println((int)(c[i].getArea()) + " "); } } }
0
0
4
NUKUSEYO
2022년 2월 27일
In 소스 코드 제출
/*class Book { String title; String author; void show() { System.out.println(title + " " + author); } //메소드 public Book() { this("",""); System.out.println("생성자 호출 완료"); } //생성자1 public Book(String t) { //생성자 this(t,"작자미상"); } //생성자2 public Book(String title, String author) { //생성자2 this.title = title; //this title은 나(class)의 변수, 그냥 title은 String title = 매개변수 this.author = author; } //생성자3 } public class Main { public static void main(String [] args) { Book littlePrince = new Book("어린왕자","생텍쥐페리"); Book lovestory = new Book("춘향전"); Book emptyBook = new Book(); lovestory.show(); } } class Main { int id; public Main() { this(0); System.out.println("생성자 호출"); } public Main(int x) { // 생성자는 반환형이 없다!! this.id = x; } public static void main(String[] args) { } } */ class Main { int x; public void setX(int x) { this.x = x; } public int getX() { return x; } public Main(int x) { this.x = x; } public static void main(String[] args) { Main a = new Main(1); int n = a.getX(); System.out.println(n); } }
0
0
3

NUKUSEYO

더보기
bottom of page