자바 소스 작성 도와주세요(내공 100)

자바 소스 작성 도와주세요(내공 100)

작성일 2016.10.17댓글 1건
    게시물 수정 , 삭제는 로그인 필요

1번//

import java.util.*;

public class ListExample {

public static void main(String[] args) {

BoardDao dao = new BoardDao();

List<Board> list = dao.getBoardList();

for(Board board : list) {

System.out.println(board.getTitle() + "-" + board.getContent());

}

}

 

}

class Board {

private String title;

private String content;

public Board(String title, String content) {

this.title = title;

this.content = content;

}

public String getTitle() {

return title;

}

public String getContent() {

return content;

}

}

 

class BoardDao {

// 코드 작성 부분.

}

 

// BoardDao 객체의 getBoardList() 메소드를 호출하면 List<Board> 타입의 컬렉션을 리턴한다.

// ListExample 클래스가 실행되었을 때 다음과 같이 출력될 수 있도록 BoardDao Class의 getBoardList() 메소드 작성 필요.

/* 결과창 

제목1-내용1

제목2-내용2

제목3-내용3 */​ 


2번//

import java.util.*;

public class HashSetExample {

public static void main(String[] args) {

Set<Student> set = new HashSet<Student>();

set.add(new Student(1, "홍길동"));

set.add(new Student(2, "신용권"));

set.add(new Student(3, "조민우"));

Iterator<Student> iterator = set.iterator();

while(iterator.hasNext()) {

Student student = iterator.next();

System.out.println(student.studentNum + ":" + student.name);

}

}

}

class Student {

public int studentNum;

public String name;

public Student(int studentNum, String name) {

this.studentNum = studentNum;

this.name = name;

}

public int hashCode() {

// 코드 작성

}

public boolean equals(Object obj) {

}

}

// HashSet에 Student 객체를 저장하려고 한다. 학번이 같으면 동일한 Student 라고 가정하고 중복저장이 되지 않게 하려고 함.

// Student 클래스에서 재정의해야 하는 hashCode() 와 equals 메소드의 내용을 채운다.

// Student의 해시코드는 학번이라고 가정한다. 


이거 두개 빈칸 채워주세요 ㅠ

추가내공 많이드려요


#자바 소스파일 제출 #자바 소스코드 #자바 소스 분석 툴 #자바 소스파일 확장자 #자바 소스코드 제출 #자바 소스코드 예제 #자바 소스파일 #자바 소스 #자바 소스파일 위치 #자바 소스 코드 분석 툴

profile_image 익명 작성일 -

질문이 정확하지 않아 확실치는 않지만 이렇게 작성하시면 될 것 같습니다.

class BoardDao {

java.util.List<Board> list;

public List<Board> getBoardList(){

return this.list;
}

}


public int hashCode() {

return name.length;

}


public boolean equals(Object obj) {
if (!(obj instanceof Student))
return false;
if (obj == this)
return true;
return this.name.equals(((Student) obj).name);

}

자바 소스도와주세요^^

자바 소스와 실행 화면을 출력하여 제출해야하는 레포트입니다 도와주세요~~내공걸께효^^ 1.... 프로그램을 작성하시오. 직원.java public abstract class...