java oop : object class

This commit is contained in:
haerong22
2021-03-13 14:51:57 +09:00
parent 7ebe360415
commit 9bd1813384
6 changed files with 38 additions and 52 deletions

10
JavaOOP/src/Java27.java Normal file
View File

@@ -0,0 +1,10 @@
import myObject.A;
public class Java27 {
public static void main(String[] args) {
Object o = new A();
((A) o).display();
System.out.println(o.toString());
}
}

View File

@@ -0,0 +1,13 @@
package myObject;
public class A{
public void display() {
System.out.println("A 클래스");
}
@Override
public String toString() {
return "재정의 메소드";
}
}

View File

@@ -14,6 +14,9 @@ const Form = () => {
const onChangeMine = useCallback((e) => {
setMine(e.target.value);
}, []);
const onClickBtn = useCallback((e) => {
setMine(e.target.value);
}, []);
return (
<div>

View File

@@ -1,17 +1,7 @@
import React, {memo} from "react";
import Tr from "./Tr";
import React from "react";
const Table = memo(({ tableData, dispatch }) => {
console.log("table rendered");
return (
<table>
{Array(tableData.length)
.fill()
.map((tr, i) => (
<Tr rowIndex={i} rowData={tableData[i]} dispatch={dispatch} />
))}
</table>
);
});
const Table = () => {
return <div></div>;
};
export default Table;

View File

@@ -1,24 +1,7 @@
import React, { useCallback, useRef, useEffect, memo } from "react";
import { CLICK_CELL } from "./TicTacToe";
import React from "react";
const Td = memo(({ rowIndex, cellIndex, dispatch, cellData }) => {
console.log("td rendered")
const ref = useRef([]);
useEffect(() => {
console.log(rowIndex === ref.current[0], cellIndex === ref.current[1], dispatch === ref.current[2], cellData === ref.current[3])
ref.current = [rowIndex, cellIndex, dispatch, cellData]
}, [rowIndex, cellIndex, dispatch, cellData])
const onClickTd = useCallback(() => {
console.log(rowIndex, cellIndex);
if(cellData) {
return;
}
dispatch({ type: CLICK_CELL, row: rowIndex, cell: cellIndex });
}, [cellData]);
return <td onClick={onClickTd}>{cellData}</td>;
});
const Td = () => {
return <div></div>;
};
export default Td;

View File

@@ -1,20 +1,7 @@
import React, {memo, useMemo} from "react";
import Td from "./Td";
import React from "react";
const Tr = memo(({ rowData, rowIndex, dispatch }) => {
console.log("tr rendered")
return (
<tr>
{Array(rowData.length)
.fill()
.map((td, i) => (
useMemo(
() => <Td rowIndex={rowIndex} cellIndex={i} dispatch={dispatch} cellData={rowData[i]} >{""}</Td>,
[rowData[i]],
)
))}
</tr>
);
});
const Tr = () => {
return <div></div>;
};
export default Tr;