본문 바로가기
java&eclipse 코딩 알고리즘/20231214

MemoVO

by 몽상크리에이터 2023. 12. 14.

package com.tjoeun.memo;

 

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Objects;

 

public class MemoVO {

 

public static int count;

private int idx;

private String name;

private String password;

private String memo;

private Date writeDate;

 

public MemoVO() {

// 기본생성자

}

 

public MemoVO(String name, String password, String memo) {

super(); //필드 지역변수 처리

idx = ++count;

this.name = name;

this.password = password;

this.memo = memo;

writeDate = new Date();

}

 

// 모든 데이터를 넘겨받아 초기화 시키는 생성자

public MemoVO(int idx, String name, String password, String memo, Date writeDate) {

super();

this.idx = idx;

this.name = name;

this.password = password;

this.memo = memo;

this.writeDate = writeDate;

}

 

// getters & setters => count는 뺀다. 편집할 일이 없으니깐

 

public int getIdx() {

return idx;

}

 

public void setIdx(int idx) {

this.idx = idx;

}

 

public String getName() {

return name;

}

 

public void setName(String name) {

this.name = name;

}

 

public String getPassword() {

return password;

}

 

public void setPassword(String password) {

this.password = password;

}

 

public String getMemo() {

return memo;

}

 

public void setMemo(String memo) {

this.memo = memo;

}

 

public Date getWriteDate() {

return writeDate;

}

 

public void setWriteDate(Date writeDate) {

this.writeDate = writeDate;

}

 

@Override

public String toString() { // 데이터 보는 형식지정

SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd(E) HH:mm:ss.SSS");

return String.format("%d. %s(%s)님이 %s에 남긴글\n%s", idx, name, password, sdf.format(writeDate), memo);

}

 

@Override

public int hashCode() {

return Objects.hash(idx, memo, name, password);

}

 

@Override

public boolean equals(Object obj) {

if (this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

MemoVO other = (MemoVO) obj;

return idx == other.idx && Objects.equals(memo, other.memo) && Objects.equals(name, other.name)

&& Objects.equals(password, other.password);

}

 

 

}

'java&eclipse 코딩 알고리즘 > 20231214' 카테고리의 다른 글

MemoMain  (0) 2023.12.14
MemoList  (0) 2023.12.14
StringTokenizerTest  (0) 2023.12.14
TextFileReadTest2  (0) 2023.12.14
TextFileReadTest  (0) 2023.12.14