목표



코드



// Made By TheKinGoD

import java.util.*;

public class DoublyLinkedList {

private static class Node<String> {
private String element;
private Node<String> prev;
private Node<String> next;
public Node(String e, Node<String> p, Node<String> n) {
element = e; prev = p; next = n;
}
public String getElement() { return element; }
public Node<String> getPrev() { return prev; }
public Node<String> getNext() { return next; }
public void setPrev(Node<String> p) { prev = p; }
public void setNext(Node<String> n) { next = n; }
}

private static Node<String> header;
private static Node<String> trailer;
private static int size = 0;

public static int size() { return size; }
public static boolean isEmpty() { return size == 0; }

public static String first( ) {
if (isEmpty()) return null;
return header.getNext().getElement();
}

public static String last( ) {
if (isEmpty()) return null;
return trailer.getPrev().getElement();
}

public static void addFirst(String e) {
addBetween(e, header, header.getNext());
}

public static void addLast(String e) {
addBetween(e, trailer.getPrev(), trailer);
}

public static String removeFirst( ) {
if (isEmpty()) return null;
return remove(header.getNext());
}

public static String removeLast( ) {
if (isEmpty()) return null;
return remove(trailer.getPrev());
}

private static void addBetween(String e, Node<String> predecessor, Node<String> successor) {
Node<String> newest = new Node<>(e, predecessor, successor);
predecessor.setNext(newest);
successor.setPrev(newest);
size++;
}

private static String remove(Node<String> node) {
Node<String> predecessor = node.getPrev( );
Node<String> successor = node.getNext( );
predecessor.setNext(successor);
successor.setPrev(predecessor);
size--;
return node.getElement( );
}

public static void PrintAll(){
if (isEmpty()) {
System.out.println("No Element in List!");
return;
}
System.out.println("------------------------------------------------");
Node<String> tmp = header;
for(int i = 0; i < size(); i++){
tmp = tmp.getNext();
System.out.println("DoublyLinkedList[" + i + "] = " + tmp.getElement());
}
}

public static String removing(int idx){
if (idx < 0 || idx > size() - 1) {
System.out.println("Over/UnderFlow!");
return null;
}
Node<String> tmp = header;
for(int i = 0; i <= idx; i++){
tmp = tmp.getNext();
}
remove(tmp);
return tmp.getElement();
}

public static void insertion(int idx, String e){
if (idx > size() || idx < 0) {
System.out.println("Over/UnderFlow!");
return;
}
Node<String> tmp = header;
for(int i = 0; i < idx; i++){
tmp = tmp.getNext();
}
addBetween(e, tmp, tmp.getNext());
}

public static void main(String[] args) {
header = new Node<>(null, null, null);
trailer = new Node<>(null, header, null);
header.setNext(trailer);
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("------------------------------------------------");
System.out.println("0 = End, 1 = Insert, 2 = Removing, 3 = Print All");
System.out.println("------------------------------------------------");
System.out.print("Case : ");
int Case = sc.nextInt();
if (Case == 0){
System.out.println("Program is END!");
break;
}
else if (Case == 1){
System.out.print("String : ");
String text = sc.next();
System.out.print("Index : ");
int idx = sc.nextInt();
insertion(idx, text);
}
else if (Case == 2){
System.out.print("Index : ");
int idx = sc.nextInt();
removing(idx);
}
else {
PrintAll();
}
}
}
}



실행화면


파일


DoublyLinkedList.java



목표



코드


import java.util.Scanner;

public class SinglyLinkedList {
private static class Node<Integer> { // Node
private int element; // element
private Node<Integer> next; // nextnode

public Node(int e, Node<Integer> n) { // setNode
element = e;
next = n;
}

public int getElement() { // Get Element
return element;
}

public Node<Integer> getNext() { // Get Next Node
return next;
}

public void setNext(Node<Integer> n) { // Set Next Node
next = n;
}
}

private static Node<Integer> head = null;// Initial LinkedList
private static Node<Integer> tail = null;// Initial LinkedList
private static int size = 0; // Initial LinkedList

public SinglyLinkedList(){}

public static int size() { // Get Size
return size;
}

public static boolean isEmpty() { // Empty = true, Not Empty = false
return size() == 0;
}

public static int first() { // Get First Element
if (isEmpty()) return 0; // Empty check
return head.getElement();
}

public static int last() { // Get Last Element
if (isEmpty()) return 0; // Empty check
return tail.getElement();
}

public static void addFirst(Integer e) { // Add to First
head = new Node<>(e, head); // Make Head
if (size == 0) {
tail = head;
}
size++;
}

public static void addLast(Integer e) { // Add to Last
Node<Integer> newest = new Node<>(e, null); // Make Last Node
if (isEmpty()) {
head = newest;
}
else {
tail.setNext(newest);
}
size++;
tail = newest;
}

public static void removeFirst(){ // Remove First Node
if (isEmpty()) return;
head = head.getNext();
size--;
if (size == 0) {
tail = null;
}
}
/*------------------------------------------------------
| 여기까지가 기본으로 준 함수 |
|_____________________________________________________*/
public static void insertion(Integer e, int idx){ // Add to Index
if (idx > size || idx < 0) { // Check Over/UnderFlow
System.out.println("List Over/UnderFlow!");
return;
}
if (idx == size){
addLast(e);
return;
}
if (idx == 0){
addFirst(e);
return;
}
Node<Integer> tmp = head;
for(int i = 0; i < idx - 1; i++){ // Go to Index - 1
tmp = tmp.getNext();
}
Node<Integer> insert = new Node<>(e, tmp.getNext()); // Make New Node
tmp.setNext(insert); // Input New Node to Index
size++;
}

public static void removing(int idx){ // Remove Index's Node
if (isEmpty()){ // Empty Check
System.out.println("No Element in Linked List!");
return;
}
if (idx < 0 || idx > size - 1) { // Check Over/UnderFlow
System.out.println("List Over/UnderFlow!");
return;
}
if (idx == 0){
removeFirst();
return;
}
Node<Integer> tmp = head;
for(int i = 0; i < idx - 1; i++){ // Go to Index - 1
tmp = tmp.getNext();
}
if (idx == size - 1) { // If New Node == Last
tmp.setNext(null);
size--;
return;
}
tmp.setNext(tmp.getNext().getNext()); // Else Linked Next Next Node
size--;
if (isEmpty()) {
tail = null;
}
}

public static void pall(){ // Print All Element
if (isEmpty()){ // Check Empty
System.out.println("No Element in Linked List!");
return;
}
Node<Integer> tmp = head;
System.out.println("LinkedList[0] = " + tmp.getElement()); // Print First Element
for(int i = 0; i < size - 1; i++){ // Searching all index
tmp = tmp.getNext();
System.out.println("LinkedList[" + (i + 1) + "] = " + tmp.getElement()); // Print Index, Element
}
}

public static void main(String[] args) { // Main
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("------------------------------------------------");
System.out.println("0 = End, 1 = Insert, 2 = Removing, 3 = Print All");
System.out.println("------------------------------------------------");
System.out.print("Case : ");
int Case = sc.nextInt();
if (Case == 0) {
System.out.println("Program is End!");
break;
}
else if (Case == 1) {
System.out.print("Element : ");
int text = sc.nextInt();
System.out.print("Index : ");
int idx = sc.nextInt();
insertion(text, idx);
}
else if (Case == 2) {
System.out.print("Index : ");
int idx = sc.nextInt();
removing(idx);
}
else {
System.out.println("------------------------------------------------");
pall();
}
}
sc.close();
}
}


실행화면



파일


SinglyLinkedList.java


이 한글패치는 >>  http://cafe.naver.com/starvall/25354 << 링크대로 패치 하였습니다.


베타는 이곳으로 >> [스타듀밸리] 스타듀밸리 베타 BETA 1.3 맥북 한글패치 <<

1.3 정식 버젼은 >> [스타듀밸리] 스타듀밸리 1.3 맥북 한글패치 멀티 <<


v1.2.33 이전 버전 미확인

v1.2.33 정상작동 확인



맥북에서 한글패치를 하려면 >> http://cafe.naver.com/starvall/25354 << 위 링크를 따라 해야 합니다.

하지만 많이 복잡해서 맥북을 잘 사용하지 못하시는 분들은 한글패치를 하다가 포기하거나 따라해도 한글패치가 제대로 안돼있는 경우가 있죠.

더 쉬운 방법은 이미 한글패치가 된 파일을 그대로 덮어씌우는 방법이 있습니다. 그 방법에 대해서 알아보도록 하죠.


1. 밑의 파일을 다운받고 압축을 풉니다.


>> 다운로드 <<



2. 스팀 라이브러리에서 Stardew Valley 오른쪽클릭 - 속성버튼을 누릅니다.



3. 로컬 파일 - 로컬 콘텐츠 폴더 보기... 를 클릭합니다.



4. Stardew Valley/Contents/Resources 안에 있는 Content폴더를 다운받은 Content폴더와 대치 합니다. ※Contents 아님



5. 완료. 게임에 들어가서 정상작동이 되는지 확인해 봅니다.






2017 2nd Semester 한양대 에리카 프로그래밍설계방법론 4주차 실습 StudentManager


목표



코드


StudentManager.class


package sils3;


import java.util.ArrayList;

import java.util.Scanner;


public class StudentManager {

Scanner Scanner = new Scanner(System.in);

ArrayList<StudentInfo> SIL = new ArrayList<StudentInfo>();

StudentManager(){

start();

Scanner.close();

}

public void sign() { /* Sign Up Method */

String sName;

int sAge;

int sSID;

String sPhoneN;

System.out.print("Input Name : "); /* input Name */

sName = Scanner.next();

System.out.print("Input Age : "); /* input Age */

sAge = Scanner.nextInt();

System.out.print("Input Student ID : "); /* input StudentID */

sSID = Scanner.nextInt();

System.out.print("Input Phone Number : "); /* input PhoneNumber */

sPhoneN = Scanner.next();

StudentInfo stInfo = new StudentInfo(sName, sAge, sSID, sPhoneN);

System.out.println(stInfo);

SIL.add(stInfo); /* Add to ArrayList */

 

}

public void modify() { /* Modify Method */

int cnt = 1; /* for "No." Print */

int modiN;

int mAge, mSID;

String mName, mPhoneN;

System.out.println("No.          Name         Age          Student ID   Phone Number");

for ( StudentInfo student : SIL ) {

System.out.format("%-13d%-13s%-13d%-13d%-13s\n", cnt, student.getUserName(), student.getUserAge(), student.getUserSID(), student.getUserPhoneN());

cnt++;

}

System.out.print("==> Input modify No. : ");

modiN = Scanner.nextInt();

System.out.print("Input Name : "); /* Name input */

mName = Scanner.next();

System.out.print("Input Age : "); /* Age input */

mAge = Scanner.nextInt();

System.out.print("Input Student ID : "); /* StudentID input */

mSID = Scanner.nextInt();

System.out.print("Input Phone Number : "); /* PhoneNumber input */

mPhoneN = Scanner.next();

StudentInfo stInfo = new StudentInfo(mName, mAge, mSID, mPhoneN);

SIL.set(modiN-1, stInfo); /* Set ArrayList's (modiN-1)th Index Data */

}

public void delete() {

int cnt = 1; /* for "No." print */

System.out.println("No.          Name         Age          Student ID   Phone Number");

for ( StudentInfo student : SIL ) {

System.out.format("%-13d%-13s%-13d%-13d%-13s\n", cnt, student.getUserName(), student.getUserAge(), student.getUserSID(), student.getUserPhoneN());

cnt++;

}

System.out.print("==> Input delete No. : ");

int delN = Scanner.nextInt();

SIL.remove(delN-1); /* Remove ArrayList's (delN-1)th Index Data */

}

public void list() {

System.out.println("Name         Age          Student ID   Phone Number");

for ( StudentInfo student : SIL ) {

System.out.format("%-13s%-13d%-13d%-13s\n", student.getUserName(), student.getUserAge(), student.getUserSID(), student.getUserPhoneN() );

}

}

public void namesearch() {

System.out.print("Input Search Name : ");

String nsName = Scanner.next();

int cnt = 1, cntn = 0; /* cnt for "No." print cntn for PrintForm only First */

for ( StudentInfo student : SIL ) {

if (student.getUserName().equals(nsName)) { /* if student's name == nsName */

if (cntn == 0) { /* First Form */

System.out.println("No.          Name         Age          Student ID   Phone Number");

cntn++;

}

System.out.format("%-13d%-13s%-13d%-13d%-13s\n", cnt ,student.getUserName(), student.getUserAge(), student.getUserSID(), student.getUserPhoneN() );

}

cnt++;

}

}

public void IDsearch() {

System.out.print("Input Search ID : ");

int nsSID = Scanner.nextInt();

int cnt = 1, cntn = 0; /* cnt for "No." print cntn for PrintForm only First */

for ( StudentInfo student : SIL ) {

if (student.getUserSID() == nsSID) { /* if student's ID == nsSID */

if (cntn == 0) { /* First Form */

System.out.println("No.          Name         Age          Student ID   Phone Number");

cntn++;

}

System.out.format("%-13d%-13s%-13d%-13d%-13s\n", cnt ,student.getUserName(), student.getUserAge(), student.getUserSID(), student.getUserPhoneN() );

}

cnt++;

}

}

public void quit() {

System.out.println("Porgram Finished");

}

void start() {

while(true) {

System.out.println("--------------------------------------------------------------------------");

System.out.println("1) sign up 2) modify 3) delete 4) list 5) name search 6) ID search 7) Quit");

System.out.println("--------------------------------------------------------------------------");

int caseN = Scanner.nextInt();

if (caseN == 1) {

sign();

}

if (caseN == 2) {

modify();

}

if (caseN == 3) {

delete();

}

if (caseN == 4) {

list();

}

if (caseN == 5) {

namesearch();

}

if (caseN == 6) {

IDsearch();

}

if (caseN == 7) {

quit();

break;

}

}

}


}



Run.class


package sils3;


public class Run {


public static void main(String[] args) {

new StudentManager(); /* Create StudentManager Class */

}

}



UserInfo.class


package sils3;


public class UserInfo {

private String userName;

private int userAge;

public UserInfo(String uName, int uAge) {

userName = uName;

userAge = uAge;

}

void setUserName(String uName) {

userName = uName;

}

void setUserAge(int uAge) {

userAge = uAge;

}

String getUserName() {

return userName;

}

int getUserAge() {

return userAge;

}

}



StudentInfo.class   


package sils3;


public class StudentInfo extends UserInfo {

private int userSID;

private String userPhoneN;


public StudentInfo(String uName, int uAge, int uSID, String uPhoneN) {

super(uName, uAge);

userSID = uSID;

userPhoneN = uPhoneN

}

void setUserSID(int uSID) {

userSID = uSID;

}

void setUserAge(String uPhoneN) {

userPhoneN = uPhoneN;

}

int getUserSID() {

return userSID;

}

String getUserPhoneN() {

return userPhoneN;

}

}



실행 화면



파일


2017011830_김재현.zip