From b89135a071bf61d719eba5e19a5e92b356e0b867 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Thu, 4 May 2023 18:21:55 +0900 Subject: [PATCH 01/73] feat: setup smartstore project --- .gitignore | 5 ++ build.gradle | 19 ++++ gradlew | 234 ++++++++++++++++++++++++++++++++++++++++++++++++ gradlew.bat | 89 ++++++++++++++++++ settings.gradle | 2 + 5 files changed, 349 insertions(+) create mode 100644 .gitignore create mode 100644 build.gradle create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3551ef14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.gradle +.idea +build +gradle +out diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..3cae2d72 --- /dev/null +++ b/build.gradle @@ -0,0 +1,19 @@ +plugins { + id 'java' +} + +group 'org.example' +version '1.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/gradlew b/gradlew new file mode 100644 index 00000000..1b6c7873 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..92426426 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'KDTBE5_Java_ToyProject' + From 525d6d9740e89d494d75b6d5ac66a361b1c2d2c8 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 8 May 2023 00:23:50 +0900 Subject: [PATCH 02/73] =?UTF-8?q?docs(=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D):=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/feature_list.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/feature_list.md diff --git a/docs/feature_list.md b/docs/feature_list.md new file mode 100644 index 00000000..e74175e2 --- /dev/null +++ b/docs/feature_list.md @@ -0,0 +1,36 @@ +# 기능 목록 + + +## 콘솔, 파일을 통해 고객 등급(group) 분류 기준 입력, 설정, 삭제 +1. [ ] 콘솔 및 파일을 통해 분류 기준 입력 받음 +2. [ ] 분류 기준 설정 +3. [ ] 분류 기준 삭제 + + +## 고객 등급 분류 기능 +(정렬 시 오름차순 또는 내림차순 선택 기능 추가) +1.[ ] 분류기준에 따른 고객 분류 +2.[ ] 분류기준으로 분류된 고객 정보 출력 +3.[ ] 분류기준으로 분류된 고객 정보를 이름순(name) 정렬 +4.[ ] 분류기준으로 분류된 고객 정보를 총 이용시간(hours) 순으로 정렬 +5. [ ] 분류기준으로 분류된 고객 정보를 총 결제금액(totalAmount) 순으로 정렬 + +## 콘솔, 파일을 통해 고객 정보 입력, 추가, 삭제 +1. [ ] 고객 정보 입력 기능 +2. [ ] 고객 정보 추가 +3. [ ] 고객 정보 삭제 + + +## 예외처리 +1. [ ] 고객 분류 기준이 추가될 경우 수정된 분류기준에 따라 고객 재분류 가능해야한다. +2. [ ] 고객 정보가 추가될 때, 다음 시나리오에 대한 예외 처리 + - 배열의 크기가 부족할 수 있음 + - 배열 크기 더블링 (x2, x1.xx) + - 기존 배열의 크기가 5 일 경우, 6번째 고객이 들어온다고 가정. + - 배열의 크기를 더블링 시키고 (10) + - 기존 배열의 데이터를 복붙하고 + - 6번째 고객의 정보도 저장한다. +3. [ ] 고객 정보가 추가될 때, 다음 시나리오에 대한 예외 처리 + - 배열 구멍 뚫리면 안됨 + - 0, 1, 2: null, 3, 4 ⇒ 0, 1, 2, 3, 4: null +[ ] 배열의 저장범위를 벗어나게 되면 생기는 예외 처리 \ No newline at end of file From a6be3c3e41e3e2abf4c5972182d67e330ad9a6f8 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 12:18:38 +0900 Subject: [PATCH 03/73] =?UTF-8?q?feat:=20customer=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 고객을 의미하는 Customer클래스와 고객객체를 담을 Customers 클래스 생성 --- .../java/me/smartstore/customer/Customer.java | 85 +++++++++++++++++++ .../me/smartstore/customer/Customers.java | 26 ++++++ 2 files changed, 111 insertions(+) create mode 100644 src/main/java/me/smartstore/customer/Customer.java create mode 100644 src/main/java/me/smartstore/customer/Customers.java diff --git a/src/main/java/me/smartstore/customer/Customer.java b/src/main/java/me/smartstore/customer/Customer.java new file mode 100644 index 00000000..d2894c86 --- /dev/null +++ b/src/main/java/me/smartstore/customer/Customer.java @@ -0,0 +1,85 @@ +package me.smartstore.customer; + +import me.smartstore.group.GroupType; + +import java.util.Objects; + +public class Customer { + private String name; + private String id; + private int hours; + private int totalAmount; + private GroupType group; + + public Customer(String name, String id, int hours, int totalAmount, GroupType group) { + this.name = name; + this.id = id; + this.hours = hours; + this.totalAmount = totalAmount; + this.group = group; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getHours() { + return hours; + } + + public void setHours(int hours) { + this.hours = hours; + } + + public int getTotalAmount() { + return totalAmount; + } + + public void setTotalAmount(int totalAmount) { + this.totalAmount = totalAmount; + } + + public GroupType getGroup() { + return group; + } + + public void setGroup(GroupType group) { + this.group = group; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Customer customer = (Customer) o; + return hours == customer.hours && totalAmount == customer.totalAmount && Objects.equals(name, customer.name) && Objects.equals(id, customer.id) && group == customer.group; + } + + @Override + public int hashCode() { + return Objects.hash(name, id, hours, totalAmount, group); + } + + @Override + public String toString() { + return "Customer{" + + "name='" + name + '\'' + + ", id='" + id + '\'' + + ", hours=" + hours + + ", totalAmount=" + totalAmount + + ", group=" + group + + '}'; + } +} diff --git a/src/main/java/me/smartstore/customer/Customers.java b/src/main/java/me/smartstore/customer/Customers.java new file mode 100644 index 00000000..4fa9c3bf --- /dev/null +++ b/src/main/java/me/smartstore/customer/Customers.java @@ -0,0 +1,26 @@ +package me.smartstore.customer; + +import java.util.Arrays; + +public class Customers { + private static Customers instance; + private Customer[] customers; + + public static Customers getInstance() { + if (instance == null) { + instance = new Customers(); + } + return instance; + } + + public Customer[] getCustomers() { + return customers; + } + + @Override + public String toString() { + return "Customers{" + + "customers=" + Arrays.toString(customers) + + '}'; + } +} From c793b694d0b9571d29e113d00c7d1bbe7f325322 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 15:38:08 +0900 Subject: [PATCH 04/73] =?UTF-8?q?feat:=20ArrayList=20=EC=A7=81=EC=A0=91=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EB=B0=8F=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 향후 Map, Set등 필요 시 컬렉션 프레임워크를 직접 구현하기 위해 java의 Collection과 유사한 MyCollection도 생성함. --- .../smartstore/collections/MyArrayList.java | 97 +++++++++++++++++++ .../smartstore/collections/MyCollection.java | 15 +++ .../me/smartstore/collections/MyList.java | 10 ++ 3 files changed, 122 insertions(+) create mode 100644 src/main/java/me/smartstore/collections/MyArrayList.java create mode 100644 src/main/java/me/smartstore/collections/MyCollection.java create mode 100644 src/main/java/me/smartstore/collections/MyList.java diff --git a/src/main/java/me/smartstore/collections/MyArrayList.java b/src/main/java/me/smartstore/collections/MyArrayList.java new file mode 100644 index 00000000..a1838550 --- /dev/null +++ b/src/main/java/me/smartstore/collections/MyArrayList.java @@ -0,0 +1,97 @@ +package me.smartstore.collections; + +import java.util.Arrays; + +public class MyArrayList implements MyList { + private int size; + private static final int DEFAULT_CAPACITY = 50; + private T[] elements; + + public MyArrayList() { + this.size = 0; + this.elements = (T[]) new Object[DEFAULT_CAPACITY]; + } + + @Override + public void add(T t) { + if (size == elements.length) { + elements = Arrays.copyOf(elements, size * 2); + } + this.elements[size++] = t; + } + + //@Todo: 테스트해야됨 + @Override + public void add(int index, T t) { + if (size == elements.length) { + elements = Arrays.copyOf(elements, size * 2); + } + System.arraycopy(elements, index, elements, index + 1, size - index); + elements[index] = t; + size++; + } + + @Override + public void clear() { + elements = (T[]) new Object[DEFAULT_CAPACITY]; + size = 0; + + } + + @Override + public boolean contains(T t) { + for (T element : elements) { + if (element.equals(t)) { + return true; + } + } + return false; + } + + @Override + public boolean isEmpty() { + return size == 0; + } + + @Override + public boolean remove(T t) { + for (int i = 0; i < size; i++) { + if (elements[i].equals(t)) { + for (int j = i; j < size - 1; j++) { + elements[j] = elements[j + 1]; + } + size--; + return true; + } + } + return false; + } + + @Override + public int size() { + return size; + } + + @Override + public void set(int index, T t) { + + } + + @Override + public int indexOf(T t) { + for (int i = 0; i < size; i++) { + if (elements[i].equals(t)) { + return i; + } + } + return -1; + } + + @Override + public T get(int index) { + if (index < 0 || index >= size) { + throw new IndexOutOfBoundsException(); + } + return elements[index]; + } +} diff --git a/src/main/java/me/smartstore/collections/MyCollection.java b/src/main/java/me/smartstore/collections/MyCollection.java new file mode 100644 index 00000000..e2a116a4 --- /dev/null +++ b/src/main/java/me/smartstore/collections/MyCollection.java @@ -0,0 +1,15 @@ +package me.smartstore.collections; + +public interface MyCollection { + void add(T t); + + void clear(); + + boolean contains(T t); + + boolean isEmpty(); + + boolean remove(T t); + + int size(); +} diff --git a/src/main/java/me/smartstore/collections/MyList.java b/src/main/java/me/smartstore/collections/MyList.java new file mode 100644 index 00000000..fb2c4451 --- /dev/null +++ b/src/main/java/me/smartstore/collections/MyList.java @@ -0,0 +1,10 @@ +package me.smartstore.collections; + +public interface MyList extends MyCollection { + void add(int index, T t); + void set(int index, T t); + + int indexOf(T t); + + T get(int index); +} From 8fcac44645957e385e636e1cda7fce3752d6661b Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 15:42:40 +0900 Subject: [PATCH 05/73] =?UTF-8?q?fix(Customers):=20Customer=EB=B0=B0?= =?UTF-8?q?=EC=97=B4=20=EC=82=AC=EC=9A=A9=20->=20MyArrayList?= =?UTF-8?q?=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/customer/Customers.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/smartstore/customer/Customers.java b/src/main/java/me/smartstore/customer/Customers.java index 4fa9c3bf..bf88029f 100644 --- a/src/main/java/me/smartstore/customer/Customers.java +++ b/src/main/java/me/smartstore/customer/Customers.java @@ -1,10 +1,12 @@ package me.smartstore.customer; +import me.smartstore.collections.MyArrayList; + import java.util.Arrays; public class Customers { private static Customers instance; - private Customer[] customers; + private MyArrayList customers; public static Customers getInstance() { if (instance == null) { @@ -13,14 +15,14 @@ public static Customers getInstance() { return instance; } - public Customer[] getCustomers() { + public MyArrayList getCustomers() { return customers; } @Override public String toString() { return "Customers{" + - "customers=" + Arrays.toString(customers) + + "customers=" + customers + '}'; } } From 2cfa802fb66bda39c05f2ca929a13aec55445e79 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 16:32:39 +0900 Subject: [PATCH 06/73] =?UTF-8?q?docs(=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D):=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A0=9C=EB=AA=A9=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 배포된 예시 프로그램 내 고객 정보 및 고객 등급 분류 기준에 대한 조회 기능이 있음을 확인, 기능 목록에 반영함. --- docs/feature_list.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/feature_list.md b/docs/feature_list.md index e74175e2..db8c18ca 100644 --- a/docs/feature_list.md +++ b/docs/feature_list.md @@ -1,10 +1,11 @@ # 기능 목록 -## 콘솔, 파일을 통해 고객 등급(group) 분류 기준 입력, 설정, 삭제 +## 콘솔, 파일을 통해 고객 등급(group) 분류 기준 CRUD 1. [ ] 콘솔 및 파일을 통해 분류 기준 입력 받음 2. [ ] 분류 기준 설정 -3. [ ] 분류 기준 삭제 +3. [ ] 분류 기준 조회 +4. [ ] 분류 기준 삭제 ## 고객 등급 분류 기능 @@ -15,10 +16,11 @@ 4.[ ] 분류기준으로 분류된 고객 정보를 총 이용시간(hours) 순으로 정렬 5. [ ] 분류기준으로 분류된 고객 정보를 총 결제금액(totalAmount) 순으로 정렬 -## 콘솔, 파일을 통해 고객 정보 입력, 추가, 삭제 +## 콘솔, 파일을 통해 고객 정보 CRUD 1. [ ] 고객 정보 입력 기능 2. [ ] 고객 정보 추가 -3. [ ] 고객 정보 삭제 +3. [ ] 고객 정보 조회 +4. [ ] 고객 정보 삭제 ## 예외처리 From 65e9bd9a886014ba98e97d9f20ec219c5e5874c8 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 16:46:57 +0900 Subject: [PATCH 07/73] =?UTF-8?q?fix(Customers):=20=EC=8B=B1=EA=B8=80?= =?UTF-8?q?=ED=86=A4=20=EA=B0=9D=EC=B2=B4=EC=9D=B4=EA=B8=B0=EC=97=90=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=83=9D=EC=84=B1=EC=9E=90=EB=A5=BC=20pri?= =?UTF-8?q?vate=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/customer/Customers.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/me/smartstore/customer/Customers.java b/src/main/java/me/smartstore/customer/Customers.java index bf88029f..431b9ca1 100644 --- a/src/main/java/me/smartstore/customer/Customers.java +++ b/src/main/java/me/smartstore/customer/Customers.java @@ -8,6 +8,7 @@ public class Customers { private static Customers instance; private MyArrayList customers; + private Customers(){} public static Customers getInstance() { if (instance == null) { instance = new Customers(); From dba14a45de9d4493029a1a4ec4a2a4a32b48fe1f Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 17:04:47 +0900 Subject: [PATCH 08/73] =?UTF-8?q?feat:=20menu=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 콘솔 프로그램 내 고객 및 고객 등급 정보를 CRUD하기 위한 기능 구현 용도로 패키지 추가함. --- .../java/me/smartstore/menu/CustomerMenu.java | 28 +++++++++++++++++++ .../java/me/smartstore/menu/GroupMenu.java | 28 +++++++++++++++++++ src/main/java/me/smartstore/menu/Menu.java | 27 ++++++++++++++++++ .../java/me/smartstore/menu/SummaryMenu.java | 8 ++++++ .../java/me/smartstore/menu/orderType.java | 6 ++++ 5 files changed, 97 insertions(+) create mode 100644 src/main/java/me/smartstore/menu/CustomerMenu.java create mode 100644 src/main/java/me/smartstore/menu/GroupMenu.java create mode 100644 src/main/java/me/smartstore/menu/Menu.java create mode 100644 src/main/java/me/smartstore/menu/SummaryMenu.java create mode 100644 src/main/java/me/smartstore/menu/orderType.java diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java new file mode 100644 index 00000000..dfea20d1 --- /dev/null +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -0,0 +1,28 @@ +package me.smartstore.menu; + +public class CustomerMenu extends Menu { + @Override + public void addData() { + + } + + @Override + public void viewData() { + + } + + @Override + public void updateData() { + + } + + @Override + public void DeleteData() { + + } + + @Override + public void back() { + + } +} diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java new file mode 100644 index 00000000..e6a3d7c8 --- /dev/null +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -0,0 +1,28 @@ +package me.smartstore.menu; + +public class GroupMenu extends Menu{ + @Override + public void addData() { + + } + + @Override + public void viewData() { + + } + + @Override + public void updateData() { + + } + + @Override + public void DeleteData() { + + } + + @Override + public void back() { + + } +} diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java new file mode 100644 index 00000000..5982f620 --- /dev/null +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -0,0 +1,27 @@ +package me.smartstore.menu; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +public class Menu { + protected BufferedReader br; + + public Menu() { + br = new BufferedReader(new InputStreamReader(System.in)); + } + + void addData() { + } + + void viewData() { + } + + void updateData() { + } + + void DeleteData() { + } + + void back() { + } +} diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java new file mode 100644 index 00000000..6d175a52 --- /dev/null +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -0,0 +1,8 @@ +package me.smartstore.menu; + +public class SummaryMenu extends Menu { + @Override + public void back(){ + + } +} diff --git a/src/main/java/me/smartstore/menu/orderType.java b/src/main/java/me/smartstore/menu/orderType.java new file mode 100644 index 00000000..7a2f9fa5 --- /dev/null +++ b/src/main/java/me/smartstore/menu/orderType.java @@ -0,0 +1,6 @@ +package me.smartstore.menu; + +public enum orderType { + ACSENDING, + DESCENDING +} From f658e9c86e435e88ea5f3029faad14bf93418761 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 19:20:10 +0900 Subject: [PATCH 09/73] =?UTF-8?q?feat(menu):=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/Menu.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 5982f620..335c99eb 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -1,7 +1,9 @@ package me.smartstore.menu; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; +import java.util.InputMismatchException; public class Menu { protected BufferedReader br; @@ -10,6 +12,36 @@ public Menu() { br = new BufferedReader(new InputStreamReader(System.in)); } + protected void initMenu() { + printInitMenu(); + int menuNumber = 0; + while (menuNumber < 1 || menuNumber > 4) { + try { + menuNumber = readInt(); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + } + + private void printInitMenu() { + System.out.println("=============================="); + System.out.println("1. 고객 등급 기준 설정"); + System.out.println("2. 고객 정보"); + System.out.println("3. 등급별 고객 정보 요약"); + System.out.println("4. 프로그램 종료"); + System.out.println("=============================="); + System.out.print("메뉴번호를 입력해주세요: "); + + } + + //@Todo 예외처리 + private int readInt() throws IOException { + String input = br.readLine(); + int newInt = Integer.parseInt(input); + return newInt; + } + void addData() { } From ed53bb1c61c8490da11c3c6ea123c7aa2c4d095f Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 19:37:48 +0900 Subject: [PATCH 10/73] =?UTF-8?q?fix(menu):=20=EB=8D=B0=EC=9D=B4=ED=84=B0C?= =?UTF-8?q?RUD=EB=A9=94=EC=84=9C=EB=93=9C=20DataCRUD=EC=9D=B8=ED=84=B0?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=8A=A4=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRUD메서드가 부모클래스 Menu에 있는 것이 부적절하다고 생각되어 인터페이스로 분리하였습니다. --- src/main/java/me/smartstore/menu/CustomerMenu.java | 2 +- src/main/java/me/smartstore/menu/DataCRUD.java | 12 ++++++++++++ src/main/java/me/smartstore/menu/GroupMenu.java | 2 +- src/main/java/me/smartstore/menu/Menu.java | 13 +------------ 4 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 src/main/java/me/smartstore/menu/DataCRUD.java diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index dfea20d1..dce9d8c6 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -1,6 +1,6 @@ package me.smartstore.menu; -public class CustomerMenu extends Menu { +public class CustomerMenu extends Menu implements DataCRUD { @Override public void addData() { diff --git a/src/main/java/me/smartstore/menu/DataCRUD.java b/src/main/java/me/smartstore/menu/DataCRUD.java new file mode 100644 index 00000000..56191250 --- /dev/null +++ b/src/main/java/me/smartstore/menu/DataCRUD.java @@ -0,0 +1,12 @@ +package me.smartstore.menu; + +public interface DataCRUD { + + void addData(); + + void viewData(); + + void updateData(); + + void DeleteData(); +} diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index e6a3d7c8..b6550aec 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -1,6 +1,6 @@ package me.smartstore.menu; -public class GroupMenu extends Menu{ +public class GroupMenu extends Menu implements DataCRUD{ @Override public void addData() { diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 335c99eb..68122f8a 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -42,18 +42,7 @@ private int readInt() throws IOException { return newInt; } - void addData() { - } - - void viewData() { - } - - void updateData() { - } - - void DeleteData() { - } + protected void back(){ - void back() { } } From 6b39430465551a3fac0ae61b805a20908f58e2c7 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 19:46:55 +0900 Subject: [PATCH 11/73] =?UTF-8?q?feat(CustomerMenu):=20=EA=B3=A0=EA=B0=9D?= =?UTF-8?q?=20=EB=A9=94=EB=89=B4=EC=9D=98=20=EC=B4=88=EA=B8=B0=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20=EC=B6=9C=EB=A0=A5=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/CustomerMenu.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index dce9d8c6..564076c2 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -3,7 +3,7 @@ public class CustomerMenu extends Menu implements DataCRUD { @Override public void addData() { - + } @Override @@ -25,4 +25,15 @@ public void DeleteData() { public void back() { } + + public void printCustomerInitMenu(){ + System.out.println("=============================="); + System.out.println("1. 고객 정보 추가"); + System.out.println("2. 고객 정보 조회"); + System.out.println("3. 고객 정보 수정"); + System.out.println("4. 고객 정보 삭제"); + System.out.println("5. 뒤로 가기"); + System.out.println("=============================="); + System.out.print("메뉴번호를 입력해주세요: "); + } } From d824b4c9d543a50a3f46cffffac5f1e07d9eeada Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 20:35:28 +0900 Subject: [PATCH 12/73] =?UTF-8?q?feat(CustomerMenu):=20=EA=B3=A0=EA=B0=9D?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/feature_list.md | 4 ++- .../java/me/smartstore/menu/CustomerMenu.java | 28 +++++++++++++++++-- src/main/java/me/smartstore/menu/Menu.java | 5 +++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/docs/feature_list.md b/docs/feature_list.md index db8c18ca..1eb17bf0 100644 --- a/docs/feature_list.md +++ b/docs/feature_list.md @@ -5,6 +5,7 @@ 1. [ ] 콘솔 및 파일을 통해 분류 기준 입력 받음 2. [ ] 분류 기준 설정 3. [ ] 분류 기준 조회 +3. [ ] 분류 기준 수정 4. [ ] 분류 기준 삭제 @@ -18,7 +19,8 @@ ## 콘솔, 파일을 통해 고객 정보 CRUD 1. [ ] 고객 정보 입력 기능 -2. [ ] 고객 정보 추가 +2. [x] 고객 정보 추가 +2. [ ] 고객 정보 수정 3. [ ] 고객 정보 조회 4. [ ] 고객 정보 삭제 diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index 564076c2..eb2be3f8 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -1,9 +1,33 @@ package me.smartstore.menu; +import me.smartstore.collections.MyArrayList; +import me.smartstore.customer.Customer; +import java.io.IOException; + public class CustomerMenu extends Menu implements DataCRUD { @Override public void addData() { - + try { + Customer customer = inputCustomerData(); + MyArrayList customerList = customers.getCustomers(); + customerList.add(customer); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + private Customer inputCustomerData() throws IOException { + //이름, id, 누적 시간, 누적 결제 금액을 차례로 입력받도록 함. + System.out.println("이름을 입력하세요"); + String name = br.readLine(); + System.out.println("ID를 입력하세요"); + String id = br.readLine(); + System.out.println("누적 이용시간을 입력하세요."); + int hour = Integer.parseInt(br.readLine()); + System.out.println("누적 결제금액을 입력하세요."); + int totalAmount = Integer.parseInt(br.readLine()); + + return new Customer(name, id, hour, totalAmount); } @Override @@ -26,7 +50,7 @@ public void back() { } - public void printCustomerInitMenu(){ + public void printCustomerInitMenu() { System.out.println("=============================="); System.out.println("1. 고객 정보 추가"); System.out.println("2. 고객 정보 조회"); diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 68122f8a..5c12ca16 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -1,15 +1,18 @@ package me.smartstore.menu; +import me.smartstore.customer.Customers; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import java.util.InputMismatchException; public class Menu { protected BufferedReader br; + protected Customers customers; public Menu() { br = new BufferedReader(new InputStreamReader(System.in)); + customers=Customers.getInstance(); } protected void initMenu() { From 7317683493100fc10b9a71a4b0590a54b89d2a66 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 9 May 2023 20:39:59 +0900 Subject: [PATCH 13/73] =?UTF-8?q?feat(CustomerMenu):=20=EA=B3=A0=EA=B0=9D?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 모든 고객의 정보를 조회할 수 있도록 리스트의 모든 요소를 출력했습니다. --- .../java/me/smartstore/collections/MyCollection.java | 2 +- src/main/java/me/smartstore/menu/CustomerMenu.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/smartstore/collections/MyCollection.java b/src/main/java/me/smartstore/collections/MyCollection.java index e2a116a4..5038cc32 100644 --- a/src/main/java/me/smartstore/collections/MyCollection.java +++ b/src/main/java/me/smartstore/collections/MyCollection.java @@ -1,6 +1,6 @@ package me.smartstore.collections; -public interface MyCollection { +public interface MyCollection extends Iterable { void add(T t); void clear(); diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index eb2be3f8..0b4b99f7 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -2,6 +2,8 @@ import me.smartstore.collections.MyArrayList; import me.smartstore.customer.Customer; +import me.smartstore.customer.Customers; + import java.io.IOException; public class CustomerMenu extends Menu implements DataCRUD { @@ -16,6 +18,7 @@ public void addData() { } } + //@Todo 예외처리 private Customer inputCustomerData() throws IOException { //이름, id, 누적 시간, 누적 결제 금액을 차례로 입력받도록 함. System.out.println("이름을 입력하세요"); @@ -30,9 +33,13 @@ private Customer inputCustomerData() throws IOException { return new Customer(name, id, hour, totalAmount); } + @Override public void viewData() { - + MyArrayList customerList = customers.getCustomers(); + for(Customer customer : customerList){ + System.out.println(customer); + } } @Override From 7a24b0adad15e999368f1556a3f4ef23e75740a8 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 01:32:28 +0900 Subject: [PATCH 14/73] =?UTF-8?q?feat(CustomerMenu):=20=EA=B3=A0=EA=B0=9D?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/CustomerMenu.java | 71 ++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index 0b4b99f7..b15a4a39 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -37,14 +37,83 @@ private Customer inputCustomerData() throws IOException { @Override public void viewData() { MyArrayList customerList = customers.getCustomers(); - for(Customer customer : customerList){ + for (Customer customer : customerList) { System.out.println(customer); } } @Override public void updateData() { + viewData(); + //변경할 요소의 index를 입력받음 -> 수정 희망하는 정보 받음 + MyArrayList customerList = customers.getCustomers(); + int listSize = customerList.size(); + if (listSize < 1) { + System.out.println("고객이 존재하지 않습니다."); + return; + } + + System.out.print("수정을 희망하는 고객 번호를 입력해주세요"); + System.out.print(listSize >= 2 ? "(1~" + listSize + ")" : ""); + int customerNumber = 0; + try { + customerNumber = Integer.parseInt(br.readLine()); + } catch (IOException e) { + System.out.println(e.getMessage()); + //@Todo: 숫자 입력 받는 부분에서 문자열 등 입력 시 날 수 있는 예외 테스트로 파악, 예외처리 할 것. + } + + printCustomerUpdateMessage(); + int updateMenuNumber = 0; + try { + updateMenuNumber = Integer.parseInt(br.readLine()); + if (updateMenuNumber == 5) { + return; + } + inputNewData(updateMenuNumber, customerNumber); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + private void printCustomerUpdateMessage() { + System.out.println("=============================="); + System.out.println("수정할 정보를 선택해주세요"); + System.out.println("1. 이름"); + System.out.println("2. ID"); + System.out.println("3. 누적 이용 시간"); + System.out.println("4. 누적 결제 금액"); + System.out.println("5. 수정 취소"); + System.out.println("=============================="); + System.out.print("수정할 정보를 선택해주세요(1~5): "); + + } + private void inputNewData(int updateMenuNumber, int customerNumber) throws IOException { + MyArrayList customerList = customers.getCustomers(); + Customer customer = customerList.get(customerNumber); + + if (updateMenuNumber == 1) { + System.out.println("새로운 이름을 입력해주세요."); + String name = br.readLine(); + customer.setName(name); + return; + } + if (updateMenuNumber == 2) { + System.out.println("새로운 ID를 입력해주세요."); + String id = br.readLine(); + customer.setId(id); + return; + } + if (updateMenuNumber == 3) { + System.out.println("새로운 누적 이용 시간을 입력해주세요."); + int hours = Integer.parseInt(br.readLine()); + customer.setHours(hours); + return; + } + System.out.println("새로운 누적 결제 금액을 입력해주세요."); + int totalAmount = Integer.parseInt(br.readLine()); + customer.setTotalAmount(totalAmount); } @Override From 7a2c0cea6eaaed12a8d362b45acf2d2c5dada86e Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 02:07:43 +0900 Subject: [PATCH 15/73] =?UTF-8?q?typo:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20camelCase=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/CustomerMenu.java | 2 +- src/main/java/me/smartstore/menu/DataCRUD.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index b15a4a39..32250afe 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -117,7 +117,7 @@ private void inputNewData(int updateMenuNumber, int customerNumber) throws IOExc } @Override - public void DeleteData() { + public void deleteData() { } diff --git a/src/main/java/me/smartstore/menu/DataCRUD.java b/src/main/java/me/smartstore/menu/DataCRUD.java index 56191250..6d647cc5 100644 --- a/src/main/java/me/smartstore/menu/DataCRUD.java +++ b/src/main/java/me/smartstore/menu/DataCRUD.java @@ -8,5 +8,5 @@ public interface DataCRUD { void updateData(); - void DeleteData(); + void deleteData(); } From d5ec7c1080ea378adaa656dece1acc74ef336a47 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 02:25:58 +0900 Subject: [PATCH 16/73] =?UTF-8?q?feat(collections):=20index=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=9B=EC=95=84=20=EC=9A=94=EC=86=8C=EB=A5=BC=20=EC=A7=80?= =?UTF-8?q?=EC=9A=B0=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/collections/MyArrayList.java | 11 +++++++++++ src/main/java/me/smartstore/collections/MyList.java | 1 + 2 files changed, 12 insertions(+) diff --git a/src/main/java/me/smartstore/collections/MyArrayList.java b/src/main/java/me/smartstore/collections/MyArrayList.java index a1838550..c926e837 100644 --- a/src/main/java/me/smartstore/collections/MyArrayList.java +++ b/src/main/java/me/smartstore/collections/MyArrayList.java @@ -67,6 +67,17 @@ public boolean remove(T t) { return false; } + public boolean remove(int index) { + if (index < 0 || index > size - 1) { + return false; + } + for (int i = index; i < size-1; i++) { + elements[i] = elements[i+1]; + } + size--; + return true; + } + @Override public int size() { return size; diff --git a/src/main/java/me/smartstore/collections/MyList.java b/src/main/java/me/smartstore/collections/MyList.java index fb2c4451..ddfc40f7 100644 --- a/src/main/java/me/smartstore/collections/MyList.java +++ b/src/main/java/me/smartstore/collections/MyList.java @@ -6,5 +6,6 @@ public interface MyList extends MyCollection { int indexOf(T t); + boolean remove(int index); T get(int index); } From 2838e8974d66f5bd499625c25f7e90bd2d9cd8e8 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 02:26:24 +0900 Subject: [PATCH 17/73] =?UTF-8?q?feat(CustomerMenu):=20=EA=B3=A0=EA=B0=9D?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/CustomerMenu.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index 32250afe..7902809c 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -86,7 +86,6 @@ private void printCustomerUpdateMessage() { System.out.println("5. 수정 취소"); System.out.println("=============================="); System.out.print("수정할 정보를 선택해주세요(1~5): "); - } private void inputNewData(int updateMenuNumber, int customerNumber) throws IOException { @@ -118,7 +117,24 @@ private void inputNewData(int updateMenuNumber, int customerNumber) throws IOExc @Override public void deleteData() { - + viewData(); + MyArrayList customerList = customers.getCustomers(); + int listSize = customerList.size(); + if (listSize < 1) { + System.out.println("고객이 존재하지 않습니다."); + return; + } + //@Todo 뒤로가기 추가 + System.out.print("삭제할 고객 번호를 입력해주세요"); + System.out.print(listSize >= 2 ? "(1~" + listSize + ")" : ""); + int customerNumber = 0; + try { + customerNumber = Integer.parseInt(br.readLine()); + } catch (IOException e) { + System.out.println(e.getMessage()); + //@Todo: 숫자 입력 받는 부분에서 문자열 등 입력 시 날 수 있는 예외 테스트로 파악, 예외처리 할 것. + } + customerList.remove(customerNumber); } @Override From aea57110868b45fec70e4cee93fcf042223f1383 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 13:35:16 +0900 Subject: [PATCH 18/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=20=EB=93=B1?= =?UTF-8?q?=EA=B8=89=20=EA=B8=B0=EC=A4=80=EC=9D=B4=20=EB=90=98=EB=8A=94=20?= =?UTF-8?q?Parameter=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parameter클래스는 최소 이용 시간, 최소 누적 결제 금액을 필드로 갖는다. --- src/main/java/me/smartstore/group/Parameter.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/me/smartstore/group/Parameter.java diff --git a/src/main/java/me/smartstore/group/Parameter.java b/src/main/java/me/smartstore/group/Parameter.java new file mode 100644 index 00000000..66998667 --- /dev/null +++ b/src/main/java/me/smartstore/group/Parameter.java @@ -0,0 +1,11 @@ +package me.smartstore.group; + +public class Parameter { + private int minimumHours; + private int minimumTotalAmount; + + public Parameter(int minimumHours, int minimumTotalAmount) { + this.minimumHours = minimumHours; + this.minimumTotalAmount = minimumTotalAmount; + } +} From e6706527025df14c8edebf05705ba87744de8eae Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 14:15:28 +0900 Subject: [PATCH 19/73] =?UTF-8?q?feat(group):=20=EA=B3=A0=EA=B0=9D=20?= =?UTF-8?q?=EB=93=B1=EA=B8=89=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 등급의 정보를 담은 Group클래스, Group객체를 저장하기 위한 Groups클래스, 각 등급을 분류하기 위한 GroupType Enum을 생성했습니다. --- src/main/java/me/smartstore/group/Group.java | 19 ++++++++++++ .../java/me/smartstore/group/GroupType.java | 7 +++++ src/main/java/me/smartstore/group/Groups.java | 29 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 src/main/java/me/smartstore/group/Group.java create mode 100644 src/main/java/me/smartstore/group/GroupType.java create mode 100644 src/main/java/me/smartstore/group/Groups.java diff --git a/src/main/java/me/smartstore/group/Group.java b/src/main/java/me/smartstore/group/Group.java new file mode 100644 index 00000000..ea7effcb --- /dev/null +++ b/src/main/java/me/smartstore/group/Group.java @@ -0,0 +1,19 @@ +package me.smartstore.group; + +public class Group { + private GroupType customerGroup; + private Parameter parameter; + + public Group(GroupType customerGroup, Parameter parameter) { + this.customerGroup = customerGroup; + this.parameter = parameter; + } + + public GroupType getCustomerGroup() { + return customerGroup; + } + + public Parameter getParameter() { + return parameter; + } +} diff --git a/src/main/java/me/smartstore/group/GroupType.java b/src/main/java/me/smartstore/group/GroupType.java new file mode 100644 index 00000000..88827b1d --- /dev/null +++ b/src/main/java/me/smartstore/group/GroupType.java @@ -0,0 +1,7 @@ +package me.smartstore.group; + +public enum GroupType { + General, + VIP, + VVIP +} diff --git a/src/main/java/me/smartstore/group/Groups.java b/src/main/java/me/smartstore/group/Groups.java new file mode 100644 index 00000000..3520d0ba --- /dev/null +++ b/src/main/java/me/smartstore/group/Groups.java @@ -0,0 +1,29 @@ +package me.smartstore.group; + +import me.smartstore.collections.MyArrayList; + +public class Groups { + private MyArrayList groups; + private static Groups instance; + + private Groups() { + } + + public static Groups getInstance() { + if (instance == null) { + instance = new Groups(); + } + return instance; + } + + public MyArrayList getGroups() { + return groups; + } + + @Override + public String toString() { + return "Groups{" + + "groups=" + groups + + '}'; + } +} From 04354388d04a3aa0dee449134b82b89a7abcedec Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 15:28:09 +0900 Subject: [PATCH 20/73] =?UTF-8?q?feat(Customer):=20=EA=B3=A0=EA=B0=9D?= =?UTF-8?q?=EC=9D=98=20=EB=93=B1=EA=B8=89=EC=9D=84=20=EA=B3=84=EC=82=B0?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Customer객체 생성 시 해당 메서드 호출하여 세가지 GroupType 중 하나를 갖도록 했습니다. 고객 정보 수정 시에도 같은 방법 적용 예정입니다. --- .../java/me/smartstore/customer/Customer.java | 21 +++++++++++++++++-- .../java/me/smartstore/group/Parameter.java | 16 ++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/smartstore/customer/Customer.java b/src/main/java/me/smartstore/customer/Customer.java index d2894c86..fd760243 100644 --- a/src/main/java/me/smartstore/customer/Customer.java +++ b/src/main/java/me/smartstore/customer/Customer.java @@ -1,6 +1,9 @@ package me.smartstore.customer; +import me.smartstore.collections.MyArrayList; +import me.smartstore.group.Group; import me.smartstore.group.GroupType; +import me.smartstore.group.Groups; import java.util.Objects; @@ -11,12 +14,26 @@ public class Customer { private int totalAmount; private GroupType group; - public Customer(String name, String id, int hours, int totalAmount, GroupType group) { + public Customer(String name, String id, int hours, int totalAmount) { this.name = name; this.id = id; this.hours = hours; this.totalAmount = totalAmount; - this.group = group; + this.group = judgeCustomerGroup(hours, totalAmount); + } + + private GroupType judgeCustomerGroup(int hours, int totalAmount) { + //정렬된 groups요소를 돌며 그 요소의 기준 미만이라면 그 grouptype으로 설정 + Groups groups = Groups.getInstance(); + MyArrayList groupList = groups.getGroups(); + for (Group group : groupList) { + int minimumHours = group.getParameter().getMinimumHours(); + int minimumTotalAmount = group.getParameter().getMinimumTotalAmount(); + if (hours < minimumHours || totalAmount < minimumTotalAmount) { + return group.getCustomerGroup(); + } + } + return GroupType.VVIP; } public String getName() { diff --git a/src/main/java/me/smartstore/group/Parameter.java b/src/main/java/me/smartstore/group/Parameter.java index 66998667..80fb99dd 100644 --- a/src/main/java/me/smartstore/group/Parameter.java +++ b/src/main/java/me/smartstore/group/Parameter.java @@ -8,4 +8,20 @@ public Parameter(int minimumHours, int minimumTotalAmount) { this.minimumHours = minimumHours; this.minimumTotalAmount = minimumTotalAmount; } + + public int getMinimumHours() { + return minimumHours; + } + + public void setMinimumHours(int minimumHours) { + this.minimumHours = minimumHours; + } + + public int getMinimumTotalAmount() { + return minimumTotalAmount; + } + + public void setMinimumTotalAmount(int minimumTotalAmount) { + this.minimumTotalAmount = minimumTotalAmount; + } } From 4aca99006f0d1cc58735769de197bde739decb6b Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 17:10:49 +0900 Subject: [PATCH 21/73] =?UTF-8?q?feat(Parameter):=20=EA=B0=9D=EC=B2=B4=20?= =?UTF-8?q?=EC=A7=81=EC=A0=91=20=EC=B6=9C=EB=A0=A5=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20Parameter=ED=81=B4=EB=9E=98=EC=8A=A4=EC=9D=98=20tos?= =?UTF-8?q?tring()=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/group/Parameter.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/me/smartstore/group/Parameter.java b/src/main/java/me/smartstore/group/Parameter.java index 80fb99dd..5e76ba01 100644 --- a/src/main/java/me/smartstore/group/Parameter.java +++ b/src/main/java/me/smartstore/group/Parameter.java @@ -24,4 +24,12 @@ public int getMinimumTotalAmount() { public void setMinimumTotalAmount(int minimumTotalAmount) { this.minimumTotalAmount = minimumTotalAmount; } + + @Override + public String toString() { + return "Parameter{" + + "minimumHours=" + minimumHours + + ", minimumTotalAmount=" + minimumTotalAmount + + '}'; + } } From ab00b7288e2bc490141ce42a260171795f2b73f5 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 17:12:29 +0900 Subject: [PATCH 22/73] =?UTF-8?q?feat(customer):=20=EA=B3=A0=EA=B0=9D=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EB=93=B1=EA=B8=89=EB=B3=84?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A5=98=ED=95=98=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20ClassifiedCustomers=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smartstore/group/ClassifiedCustomers.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/me/smartstore/group/ClassifiedCustomers.java diff --git a/src/main/java/me/smartstore/group/ClassifiedCustomers.java b/src/main/java/me/smartstore/group/ClassifiedCustomers.java new file mode 100644 index 00000000..a7fbc8bb --- /dev/null +++ b/src/main/java/me/smartstore/group/ClassifiedCustomers.java @@ -0,0 +1,47 @@ +package me.smartstore.group; + +import me.smartstore.collections.MyArrayList; +import me.smartstore.customer.Customer; +import me.smartstore.customer.Customers; + +public class ClassifiedCustomers { + private MyArrayList classifiedByGeneral; + private MyArrayList classifiedByVIP; + private MyArrayList classifiedByVVIP; + + private static ClassifiedCustomers classifiedCustomers; + + private ClassifiedCustomers() { + } + + public static ClassifiedCustomers getInstance() { + if (classifiedCustomers == null) { + classifiedCustomers = new ClassifiedCustomers(); + } + return classifiedCustomers; + } + + public void refresh() { + Customers customers = Customers.getInstance(); + MyArrayList customerList = customers.getCustomers(); + initCustomerList(); + + for (Customer customer : customerList) { + if (customer.getGroup() == GroupType.General) { + classifiedByGeneral.add(customer); + continue; + } + if (customer.getGroup() == GroupType.VIP) { + classifiedByVIP.add(customer); + continue; + } + classifiedByVVIP.add(customer); + } + } + + private void initCustomerList() { + classifiedByGeneral = new MyArrayList<>(); + classifiedByVIP = new MyArrayList<>(); + classifiedByVVIP = new MyArrayList<>(); + } +} From 81927d5ed1bbd2c038ed3fb8228a478f94c3906c Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 17:22:42 +0900 Subject: [PATCH 23/73] =?UTF-8?q?feat(ClassifiedCustomers):=20getter=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/smartstore/group/ClassifiedCustomers.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/me/smartstore/group/ClassifiedCustomers.java b/src/main/java/me/smartstore/group/ClassifiedCustomers.java index a7fbc8bb..a1d61775 100644 --- a/src/main/java/me/smartstore/group/ClassifiedCustomers.java +++ b/src/main/java/me/smartstore/group/ClassifiedCustomers.java @@ -44,4 +44,16 @@ private void initCustomerList() { classifiedByVIP = new MyArrayList<>(); classifiedByVVIP = new MyArrayList<>(); } + + public MyArrayList getClassifiedByGeneral() { + return classifiedByGeneral; + } + + public MyArrayList getClassifiedByVIP() { + return classifiedByVIP; + } + + public MyArrayList getClassifiedByVVIP() { + return classifiedByVVIP; + } } From 35bcb981e9eecb6baa7ea3d066ef72fedc3741f2 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 17:50:27 +0900 Subject: [PATCH 24/73] =?UTF-8?q?feat(SummaryMenu):=20=EA=B3=A0=EA=B0=9D?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=9A=94=EC=95=BD(basic)=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smartstore/group/ClassifiedCustomers.java | 6 ++++ .../java/me/smartstore/menu/SummaryMenu.java | 36 ++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/group/ClassifiedCustomers.java b/src/main/java/me/smartstore/group/ClassifiedCustomers.java index a1d61775..db812537 100644 --- a/src/main/java/me/smartstore/group/ClassifiedCustomers.java +++ b/src/main/java/me/smartstore/group/ClassifiedCustomers.java @@ -9,6 +9,8 @@ public class ClassifiedCustomers { private MyArrayList classifiedByVIP; private MyArrayList classifiedByVVIP; + private MyArrayList> classifications; + private static ClassifiedCustomers classifiedCustomers; private ClassifiedCustomers() { @@ -56,4 +58,8 @@ public MyArrayList getClassifiedByVIP() { public MyArrayList getClassifiedByVVIP() { return classifiedByVVIP; } + + public MyArrayList> getClassifications() { + return classifications; + } } diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 6d175a52..6b2bdf21 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -1,8 +1,42 @@ package me.smartstore.menu; +import me.smartstore.collections.MyArrayList; +import me.smartstore.customer.Customer; +import me.smartstore.group.GroupType; + public class SummaryMenu extends Menu { + public void summary() { + classifiedCustomers.refresh(); //@Todo summary메뉴 진입 시 호출하는 걸로 변경 예정 + GroupType[] groupTypes = GroupType.values(); + MyArrayList> classifications = classifiedCustomers.getClassifications(); + + for (int i = 0; i < GroupType.values().length; i++) { + System.out.println("=============================="); + System.out.printf("그룹: %s", groupTypes[i]); + System.out.println("=============================="); + MyArrayList currentClassification = classifications.get(i); + for (int j = 0; j < currentClassification.size(); i++) { + System.out.println(j + ": " + currentClassification.get(j)); + } + } + System.out.println("=============================="); + System.out.println(); + System.out.println("=============================="); + } + @Override - public void back(){ + public void back() { + + } + public void printSummaryInitMenu() { + System.out.println("=============================="); + System.out.println("1. 고객 정보 요약"); + System.out.println("2. 고객 정보 요약(이름 순)"); + System.out.println("3. 고객 정보 요약(누적 이용 시간 순)"); + System.out.println("4. 고객 정보 요약(누적 결제 금액 순)"); + System.out.println("5. 뒤로 가기"); + System.out.println("=============================="); + System.out.print("메뉴번호를 입력해주세요: "); } } From aadef6003df8476379f45e73cdad5089254592c0 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 19:43:06 +0900 Subject: [PATCH 25/73] =?UTF-8?q?refactor(ClassifiedCustomers):=20Classifi?= =?UTF-8?q?edCustomers=ED=81=B4=EB=9E=98=EC=8A=A4=EB=A5=BC=20group?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=EC=97=90=EC=84=9C=20customer?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 잘못된 패키지에 클래스를 생성한 것을 바로잡았습니다. --- .../smartstore/{group => customer}/ClassifiedCustomers.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rename src/main/java/me/smartstore/{group => customer}/ClassifiedCustomers.java (94%) diff --git a/src/main/java/me/smartstore/group/ClassifiedCustomers.java b/src/main/java/me/smartstore/customer/ClassifiedCustomers.java similarity index 94% rename from src/main/java/me/smartstore/group/ClassifiedCustomers.java rename to src/main/java/me/smartstore/customer/ClassifiedCustomers.java index db812537..037f2716 100644 --- a/src/main/java/me/smartstore/group/ClassifiedCustomers.java +++ b/src/main/java/me/smartstore/customer/ClassifiedCustomers.java @@ -1,8 +1,7 @@ -package me.smartstore.group; +package me.smartstore.customer; import me.smartstore.collections.MyArrayList; -import me.smartstore.customer.Customer; -import me.smartstore.customer.Customers; +import me.smartstore.group.GroupType; public class ClassifiedCustomers { private MyArrayList classifiedByGeneral; From 57dd6b276b04b4371eb89e1abe5c7062ddc1900b Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 19:56:07 +0900 Subject: [PATCH 26/73] =?UTF-8?q?feat(customer):=20Customer=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=EA=B0=80=20Comparable=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 요약 모드에서 사용자가 이름순, 누적 이용 시간순, 누적 결제 금액 순 중 하나를 고르면 이 기준에 따라 정렬 가능하도록 Customer클래스를 수정하고 SortBy enum클래스를 만들었습니다. --- .../java/me/smartstore/customer/Customer.java | 24 ++++++++++++++++++- .../java/me/smartstore/customer/SortBy.java | 7 ++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/smartstore/customer/SortBy.java diff --git a/src/main/java/me/smartstore/customer/Customer.java b/src/main/java/me/smartstore/customer/Customer.java index fd760243..2ad5b612 100644 --- a/src/main/java/me/smartstore/customer/Customer.java +++ b/src/main/java/me/smartstore/customer/Customer.java @@ -7,13 +7,15 @@ import java.util.Objects; -public class Customer { +public class Customer implements Comparable { private String name; private String id; private int hours; private int totalAmount; private GroupType group; + private SortBy sortBy; + public Customer(String name, String id, int hours, int totalAmount) { this.name = name; this.id = id; @@ -72,6 +74,14 @@ public GroupType getGroup() { return group; } + public SortBy getSortBy() { + return sortBy; + } + + public void setSortBy(SortBy sortBy) { + this.sortBy = sortBy; + } + public void setGroup(GroupType group) { this.group = group; } @@ -99,4 +109,16 @@ public String toString() { ", group=" + group + '}'; } + + + @Override + public int compareTo(Customer o) { + if (sortBy == SortBy.NAME) { + return this.name.compareTo(o.name); + } + if (sortBy == SortBy.HOURS) { + return this.hours - o.hours; + } + return this.totalAmount - o.totalAmount; + } } diff --git a/src/main/java/me/smartstore/customer/SortBy.java b/src/main/java/me/smartstore/customer/SortBy.java new file mode 100644 index 00000000..d769d3af --- /dev/null +++ b/src/main/java/me/smartstore/customer/SortBy.java @@ -0,0 +1,7 @@ +package me.smartstore.customer; + +public enum SortBy { + NAME, + HOURS, + TOTAL_AMOUNT +} From 044aa534581926f0554d55711857f6b8c3de57dc Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 20:18:29 +0900 Subject: [PATCH 27/73] =?UTF-8?q?fix(customer):=20Customer=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=EC=97=90=EC=84=9C=20=EA=B0=96=EB=8D=98=20sortBy?= =?UTF-8?q?=ED=95=84=EB=93=9C=EB=A5=BC=20ClassifiedCustomer=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=EC=97=90=EC=84=9C=20=EA=B0=96=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ClassifiedCustomer에서 위 필드를 갖는 게 의미상으로도 적절할뿐더러 Customer객체와는 달리 싱글톤 객체이기에 상태를 저장하기에도 좋다고 판단했습니다. --- .../smartstore/customer/ClassifiedCustomers.java | 11 +++++++++-- .../java/me/smartstore/customer/Customer.java | 16 ++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/me/smartstore/customer/ClassifiedCustomers.java b/src/main/java/me/smartstore/customer/ClassifiedCustomers.java index 037f2716..3cd647dc 100644 --- a/src/main/java/me/smartstore/customer/ClassifiedCustomers.java +++ b/src/main/java/me/smartstore/customer/ClassifiedCustomers.java @@ -7,10 +7,9 @@ public class ClassifiedCustomers { private MyArrayList classifiedByGeneral; private MyArrayList classifiedByVIP; private MyArrayList classifiedByVVIP; - private MyArrayList> classifications; - private static ClassifiedCustomers classifiedCustomers; + private SortBy sortBy; private ClassifiedCustomers() { } @@ -61,4 +60,12 @@ public MyArrayList getClassifiedByVVIP() { public MyArrayList> getClassifications() { return classifications; } + + public SortBy getSortBy() { + return sortBy; + } + + public void setSortBy(SortBy sortBy) { + this.sortBy = sortBy; + } } diff --git a/src/main/java/me/smartstore/customer/Customer.java b/src/main/java/me/smartstore/customer/Customer.java index 2ad5b612..55499d13 100644 --- a/src/main/java/me/smartstore/customer/Customer.java +++ b/src/main/java/me/smartstore/customer/Customer.java @@ -13,8 +13,7 @@ public class Customer implements Comparable { private int hours; private int totalAmount; private GroupType group; - - private SortBy sortBy; + private ClassifiedCustomers classifiedCustomers; public Customer(String name, String id, int hours, int totalAmount) { this.name = name; @@ -22,6 +21,7 @@ public Customer(String name, String id, int hours, int totalAmount) { this.hours = hours; this.totalAmount = totalAmount; this.group = judgeCustomerGroup(hours, totalAmount); + this.classifiedCustomers = ClassifiedCustomers.getInstance(); } private GroupType judgeCustomerGroup(int hours, int totalAmount) { @@ -74,14 +74,6 @@ public GroupType getGroup() { return group; } - public SortBy getSortBy() { - return sortBy; - } - - public void setSortBy(SortBy sortBy) { - this.sortBy = sortBy; - } - public void setGroup(GroupType group) { this.group = group; } @@ -113,10 +105,10 @@ public String toString() { @Override public int compareTo(Customer o) { - if (sortBy == SortBy.NAME) { + if (classifiedCustomers.getSortBy() == SortBy.NAME) { return this.name.compareTo(o.name); } - if (sortBy == SortBy.HOURS) { + if (classifiedCustomers.getSortBy() == SortBy.HOURS) { return this.hours - o.hours; } return this.totalAmount - o.totalAmount; From 80774d758ab0f9a676667dc86e0698f09e49a81d Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 20:52:55 +0900 Subject: [PATCH 28/73] =?UTF-8?q?feat(menu):=20=EA=B3=A0=EA=B0=9D=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=A0=95=EB=A0=AC=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 사용자의 입력을 받아 적절한 OrderType을 리턴하는 inputOrderType메서드 정의 및 이를 받아 이름 순으로 정렬하는 summarySortByName()정의 --- .../java/me/smartstore/customer/SortBy.java | 5 ++- src/main/java/me/smartstore/menu/Menu.java | 12 ++++- .../java/me/smartstore/menu/SummaryMenu.java | 45 ++++++++++++++++++- .../java/me/smartstore/menu/orderType.java | 12 ++++- 4 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/smartstore/customer/SortBy.java b/src/main/java/me/smartstore/customer/SortBy.java index d769d3af..ddba7e13 100644 --- a/src/main/java/me/smartstore/customer/SortBy.java +++ b/src/main/java/me/smartstore/customer/SortBy.java @@ -3,5 +3,8 @@ public enum SortBy { NAME, HOURS, - TOTAL_AMOUNT + TOTAL_AMOUNT; + + + } diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 5c12ca16..2edb0496 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -1,6 +1,9 @@ package me.smartstore.menu; +import me.smartstore.customer.Customer; import me.smartstore.customer.Customers; +import me.smartstore.customer.ClassifiedCustomers; +import me.smartstore.group.Groups; import java.io.BufferedReader; import java.io.IOException; @@ -9,10 +12,15 @@ public class Menu { protected BufferedReader br; protected Customers customers; + protected Groups groups; + protected ClassifiedCustomers classifiedCustomers; + //@Todo 여러 객체가 필요없는 객체는 싱글톤으로 변경(Menu포함) public Menu() { br = new BufferedReader(new InputStreamReader(System.in)); - customers=Customers.getInstance(); + customers = Customers.getInstance(); + groups= Groups.getInstance(); + classifiedCustomers=ClassifiedCustomers.getInstance(); } protected void initMenu() { @@ -45,7 +53,7 @@ private int readInt() throws IOException { return newInt; } - protected void back(){ + protected void back() { } } diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 6b2bdf21..38537bd6 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -2,8 +2,11 @@ import me.smartstore.collections.MyArrayList; import me.smartstore.customer.Customer; +import me.smartstore.customer.SortBy; import me.smartstore.group.GroupType; +import java.io.IOException; + public class SummaryMenu extends Menu { public void summary() { classifiedCustomers.refresh(); //@Todo summary메뉴 진입 시 호출하는 걸로 변경 예정 @@ -20,10 +23,48 @@ public void summary() { } } System.out.println("=============================="); - System.out.println(); - System.out.println("=============================="); } + public void summarySortByName() { + OrderType orderType = inputOrderType(); + //등급 기준에 따라 정렬 + classifiedCustomers.setSortBy(SortBy.NAME); + + //@Todo summary와 겹치는 내용 추후 리팩토링 + GroupType[] groupTypes = GroupType.values(); + MyArrayList> classifications = classifiedCustomers.getClassifications(); + + for (int i = 0; i < GroupType.values().length; i++) { + System.out.println("=============================="); + System.out.printf("그룹: %s", groupTypes[i]); + System.out.println("=============================="); + MyArrayList currentClassification = classifications.get(i); + + MyList.sort(currentClassification, orderType); + for (int j = 0; j < currentClassification.size(); i++) { + System.out.println(j + ": " + currentClassification.get(j)); + } + } + } + + private OrderType inputOrderType() { + //오름차순, 내림차순 입력(OrderType이용) + int ascendingNumber = 0; + while (ascendingNumber == 0) { + try { + int input = Integer.parseInt(br.readLine()); + if (input == 1 || input == 2) { + ascendingNumber = input; + } + System.out.println("1또는 2를 입력해주세요."); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + return OrderType.getOrderType(ascendingNumber); + } + + @Override public void back() { diff --git a/src/main/java/me/smartstore/menu/orderType.java b/src/main/java/me/smartstore/menu/orderType.java index 7a2f9fa5..f26914ac 100644 --- a/src/main/java/me/smartstore/menu/orderType.java +++ b/src/main/java/me/smartstore/menu/orderType.java @@ -1,6 +1,14 @@ package me.smartstore.menu; -public enum orderType { +import me.smartstore.customer.SortBy; + +public enum OrderType { ACSENDING, - DESCENDING + DESCENDING; + + private static final OrderType[] orderTypes = OrderType.values(); + + public static OrderType getOrderType(int i) { + return orderTypes[i-1]; + } } From 6f353e27650f80e1e8075e523681e196cb1fb97e Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 21:04:55 +0900 Subject: [PATCH 29/73] =?UTF-8?q?feat(MyArrayList):=20=EC=A0=95=EB=A0=AC?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smartstore/collections/MyArrayList.java | 34 +++++++++++++++++-- .../java/me/smartstore/menu/SummaryMenu.java | 2 +- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/smartstore/collections/MyArrayList.java b/src/main/java/me/smartstore/collections/MyArrayList.java index c926e837..028cf892 100644 --- a/src/main/java/me/smartstore/collections/MyArrayList.java +++ b/src/main/java/me/smartstore/collections/MyArrayList.java @@ -1,6 +1,12 @@ package me.smartstore.collections; +import me.smartstore.menu.OrderType; + import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; public class MyArrayList implements MyList { private int size; @@ -71,8 +77,8 @@ public boolean remove(int index) { if (index < 0 || index > size - 1) { return false; } - for (int i = index; i < size-1; i++) { - elements[i] = elements[i+1]; + for (int i = index; i < size - 1; i++) { + elements[i] = elements[i + 1]; } size--; return true; @@ -105,4 +111,28 @@ public T get(int index) { } return elements[index]; } + + public void sort(OrderType orderType) { + if (orderType == OrderType.DESCENDING) { + Arrays.sort(elements, Collections.reverseOrder()); + return; + } + Arrays.sort(elements); + } + + //@Todo Iterator, forEach, Spliterator구현해야됨;; + @Override + public Iterator iterator() { + return null; + } + + @Override + public void forEach(Consumer action) { + MyList.super.forEach(action); + } + + @Override + public Spliterator spliterator() { + return MyList.super.spliterator(); + } } diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 38537bd6..ccc73782 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -40,7 +40,7 @@ public void summarySortByName() { System.out.println("=============================="); MyArrayList currentClassification = classifications.get(i); - MyList.sort(currentClassification, orderType); + currentClassification.sort(orderType); for (int j = 0; j < currentClassification.size(); i++) { System.out.println(j + ": " + currentClassification.get(j)); } From 2d6d1edbdd85cfb3f7abaee291bc7d0a9c2a6bda Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 21:13:15 +0900 Subject: [PATCH 30/73] =?UTF-8?q?feat(SummaryMenu):=20=EB=88=84=EC=A0=81?= =?UTF-8?q?=20=EC=9D=B4=EC=9A=A9=20=EC=8B=9C=EA=B0=84,=20=EB=88=84?= =?UTF-8?q?=EC=A0=81=20=EA=B2=B0=EC=A0=9C=20=EA=B8=88=EC=95=A1=20=EC=88=9C?= =?UTF-8?q?=20=EC=A0=95=EB=A0=AC=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/feature_list.md | 16 +++---- .../java/me/smartstore/menu/SummaryMenu.java | 42 ++++++++++++++++++- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/docs/feature_list.md b/docs/feature_list.md index 1eb17bf0..62d68f47 100644 --- a/docs/feature_list.md +++ b/docs/feature_list.md @@ -11,18 +11,18 @@ ## 고객 등급 분류 기능 (정렬 시 오름차순 또는 내림차순 선택 기능 추가) -1.[ ] 분류기준에 따른 고객 분류 -2.[ ] 분류기준으로 분류된 고객 정보 출력 -3.[ ] 분류기준으로 분류된 고객 정보를 이름순(name) 정렬 -4.[ ] 분류기준으로 분류된 고객 정보를 총 이용시간(hours) 순으로 정렬 -5. [ ] 분류기준으로 분류된 고객 정보를 총 결제금액(totalAmount) 순으로 정렬 +1.[X] 분류기준에 따른 고객 분류 +2.[X] 분류기준으로 분류된 고객 정보 출력 +3.[X] 분류기준으로 분류된 고객 정보를 이름순(name) 정렬 +4.[X] 분류기준으로 분류된 고객 정보를 총 이용시간(hours) 순으로 정렬 +5. [X] 분류기준으로 분류된 고객 정보를 총 결제금액(totalAmount) 순으로 정렬 ## 콘솔, 파일을 통해 고객 정보 CRUD 1. [ ] 고객 정보 입력 기능 2. [x] 고객 정보 추가 -2. [ ] 고객 정보 수정 -3. [ ] 고객 정보 조회 -4. [ ] 고객 정보 삭제 +2. [X] 고객 정보 수정 +3. [X] 고객 정보 조회 +4. [X] 고객 정보 삭제 ## 예외처리 diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index ccc73782..53e9d059 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -30,7 +30,47 @@ public void summarySortByName() { //등급 기준에 따라 정렬 classifiedCustomers.setSortBy(SortBy.NAME); - //@Todo summary와 겹치는 내용 추후 리팩토링 + //@Todo 겹치는 내용 추후 리팩토링 + GroupType[] groupTypes = GroupType.values(); + MyArrayList> classifications = classifiedCustomers.getClassifications(); + + for (int i = 0; i < GroupType.values().length; i++) { + System.out.println("=============================="); + System.out.printf("그룹: %s", groupTypes[i]); + System.out.println("=============================="); + MyArrayList currentClassification = classifications.get(i); + + currentClassification.sort(orderType); + for (int j = 0; j < currentClassification.size(); i++) { + System.out.println(j + ": " + currentClassification.get(j)); + } + } + } + + public void summarySortByHours() { + OrderType orderType = inputOrderType(); + classifiedCustomers.setSortBy(SortBy.HOURS); + + GroupType[] groupTypes = GroupType.values(); + MyArrayList> classifications = classifiedCustomers.getClassifications(); + + for (int i = 0; i < GroupType.values().length; i++) { + System.out.println("=============================="); + System.out.printf("그룹: %s", groupTypes[i]); + System.out.println("=============================="); + MyArrayList currentClassification = classifications.get(i); + + currentClassification.sort(orderType); + for (int j = 0; j < currentClassification.size(); i++) { + System.out.println(j + ": " + currentClassification.get(j)); + } + } + } + + public void summarySortByTotalAmount() { + OrderType orderType = inputOrderType(); + classifiedCustomers.setSortBy(SortBy.TOTAL_AMOUNT); + GroupType[] groupTypes = GroupType.values(); MyArrayList> classifications = classifiedCustomers.getClassifications(); From e52ddd847a263006d0b975dcba28afa9f2ee1e19 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 21:32:58 +0900 Subject: [PATCH 31/73] =?UTF-8?q?refactor(SummaryMenu):=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EB=90=98=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/SummaryMenu.java | 57 ++++--------------- 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 53e9d059..0fb108ca 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -8,16 +8,22 @@ import java.io.IOException; public class SummaryMenu extends Menu { - public void summary() { + public void summary(OrderType orderType) { classifiedCustomers.refresh(); //@Todo summary메뉴 진입 시 호출하는 걸로 변경 예정 GroupType[] groupTypes = GroupType.values(); MyArrayList> classifications = classifiedCustomers.getClassifications(); + printCustomerSummary(orderType, groupTypes, classifications); + } + private void printCustomerSummary(OrderType orderType, GroupType[] groupTypes, MyArrayList> classifications) { for (int i = 0; i < GroupType.values().length; i++) { System.out.println("=============================="); System.out.printf("그룹: %s", groupTypes[i]); System.out.println("=============================="); MyArrayList currentClassification = classifications.get(i); + if (orderType != OrderType.NONE) { + currentClassification.sort(orderType); + } for (int j = 0; j < currentClassification.size(); i++) { System.out.println(j + ": " + currentClassification.get(j)); } @@ -29,62 +35,19 @@ public void summarySortByName() { OrderType orderType = inputOrderType(); //등급 기준에 따라 정렬 classifiedCustomers.setSortBy(SortBy.NAME); - - //@Todo 겹치는 내용 추후 리팩토링 - GroupType[] groupTypes = GroupType.values(); - MyArrayList> classifications = classifiedCustomers.getClassifications(); - - for (int i = 0; i < GroupType.values().length; i++) { - System.out.println("=============================="); - System.out.printf("그룹: %s", groupTypes[i]); - System.out.println("=============================="); - MyArrayList currentClassification = classifications.get(i); - - currentClassification.sort(orderType); - for (int j = 0; j < currentClassification.size(); i++) { - System.out.println(j + ": " + currentClassification.get(j)); - } - } + summary(orderType); } public void summarySortByHours() { OrderType orderType = inputOrderType(); classifiedCustomers.setSortBy(SortBy.HOURS); - - GroupType[] groupTypes = GroupType.values(); - MyArrayList> classifications = classifiedCustomers.getClassifications(); - - for (int i = 0; i < GroupType.values().length; i++) { - System.out.println("=============================="); - System.out.printf("그룹: %s", groupTypes[i]); - System.out.println("=============================="); - MyArrayList currentClassification = classifications.get(i); - - currentClassification.sort(orderType); - for (int j = 0; j < currentClassification.size(); i++) { - System.out.println(j + ": " + currentClassification.get(j)); - } - } + summary(orderType); } public void summarySortByTotalAmount() { OrderType orderType = inputOrderType(); classifiedCustomers.setSortBy(SortBy.TOTAL_AMOUNT); - - GroupType[] groupTypes = GroupType.values(); - MyArrayList> classifications = classifiedCustomers.getClassifications(); - - for (int i = 0; i < GroupType.values().length; i++) { - System.out.println("=============================="); - System.out.printf("그룹: %s", groupTypes[i]); - System.out.println("=============================="); - MyArrayList currentClassification = classifications.get(i); - - currentClassification.sort(orderType); - for (int j = 0; j < currentClassification.size(); i++) { - System.out.println(j + ": " + currentClassification.get(j)); - } - } + summary(orderType); } private OrderType inputOrderType() { From c94b89c96e46991526e53a9e5a0e17cef449a43e Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 21:52:39 +0900 Subject: [PATCH 32/73] =?UTF-8?q?typo:=20=EC=98=A4=ED=83=80=20=EB=B0=8F=20?= =?UTF-8?q?=EB=88=84=EB=9D=BD=EB=90=9C=20=EB=B6=80=EB=B6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 2 +- .../java/me/smartstore/menu/{orderType.java => OrderType.java} | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename src/main/java/me/smartstore/menu/{orderType.java => OrderType.java} (96%) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index b6550aec..e1d1aa3d 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -17,7 +17,7 @@ public void updateData() { } @Override - public void DeleteData() { + public void deleteData() { } diff --git a/src/main/java/me/smartstore/menu/orderType.java b/src/main/java/me/smartstore/menu/OrderType.java similarity index 96% rename from src/main/java/me/smartstore/menu/orderType.java rename to src/main/java/me/smartstore/menu/OrderType.java index f26914ac..182f7423 100644 --- a/src/main/java/me/smartstore/menu/orderType.java +++ b/src/main/java/me/smartstore/menu/OrderType.java @@ -3,6 +3,7 @@ import me.smartstore.customer.SortBy; public enum OrderType { + NONE, ACSENDING, DESCENDING; From 2780185a111b04c13c43ab00c3ec50052ef4044c Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 22:10:02 +0900 Subject: [PATCH 33/73] =?UTF-8?q?feat(GroupMenu):=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=EB=A9=94=EB=89=B4=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index e1d1aa3d..2ee73357 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -25,4 +25,14 @@ public void deleteData() { public void back() { } + + public void printGroupInitMenu() { + System.out.println("=============================="); + System.out.println("1. 고객 등급 기준 추가"); + System.out.println("2. 고객 등급 기준 조회"); + System.out.println("3. 고객 등급 기준 수정"); + System.out.println("4. 뒤로 가기"); + System.out.println("=============================="); + System.out.print("메뉴번호를 입력해주세요: "); + } } From 1fd4e369765b6bca500d284f5bc27dce3f943ea8 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 22:36:54 +0900 Subject: [PATCH 34/73] =?UTF-8?q?feat(GroupMenu):=20=EA=B3=A0=EA=B0=9D=20?= =?UTF-8?q?=EB=93=B1=EA=B8=89=20=EA=B8=B0=EC=A4=80=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/GroupMenu.java | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 2ee73357..f4702d64 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -1,9 +1,64 @@ package me.smartstore.menu; -public class GroupMenu extends Menu implements DataCRUD{ +import me.smartstore.collections.MyArrayList; +import me.smartstore.group.Group; +import me.smartstore.group.GroupType; + +import java.io.IOException; + +public class GroupMenu extends Menu implements DataCRUD { @Override public void addData() { + //변경할 등급 선택 + System.out.println("다음 등급 중 하나를 선택해주세요."); + System.out.println("1. General"); + System.out.println("2. VIP"); + System.out.println("3. VVIP"); + int groupNumber = 0; + while (groupNumber == 0) { + try { + int temp = Integer.parseInt(br.readLine()); + if (temp >= 1 && temp <= 3) { + groupNumber = temp; + } else { + System.out.println("1부터 3까지의 숫자를 입력해주세요."); + } + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + //groupNumber to group + GroupType groupType = groupNumberToGroupType(groupNumber); + MyArrayList groupList = groups.getGroups(); + for (Group group : groupList) { + if (group.getCustomerGroup() == groupType) { + if (group.getParameter().getMinimumHours() != 0 || group.getParameter().getMinimumTotalAmount() != 0) { + System.out.println("이미 기준이 등록된 등급입니다."); + return; + }//입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 + int parameterNumber = Integer.parseInt(br.readLine()); + //누적 시간 입력 받음 + if (parameterNumber == 1) { + int hours = Integer.parseInt(br.readLine()); + group.getParameter().setMinimumHours(hours); + return; + } + int totalAmount = Integer.parseInt(br.readLine()); + group.getParameter().setMinimumTotalAmount(totalAmount); + return; + } + } + } + private GroupType groupNumberToGroupType(int groupNumber) { + if (groupNumber == 1) { + return GroupType.General; + } + if (groupNumber == 2) { + return GroupType.VIP; + } + return GroupType.VVIP; } @Override From a8fe309126a711387ba3d3298fce7f1109aa659c Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 22:52:03 +0900 Subject: [PATCH 35/73] =?UTF-8?q?refactor(GroupMenu):=20addData()=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/GroupMenu.java | 68 +++++++++++++------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index f4702d64..eccff1a0 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -10,10 +10,28 @@ public class GroupMenu extends Menu implements DataCRUD { @Override public void addData() { //변경할 등급 선택 + printGroupSelectionMessage(); + int groupNumber = inputGroupNumber(); + //groupNumber to group + GroupType groupType = groupNumberToGroupType(groupNumber); + //groupList에서 입력받은 등급에 해당하는 요소를 찾음 + if (insertParameter(groupType)) { + System.out.println("기준이 성공적으로 입력되었습니다."); + } + + } + + + private void printGroupSelectionMessage() { System.out.println("다음 등급 중 하나를 선택해주세요."); System.out.println("1. General"); System.out.println("2. VIP"); System.out.println("3. VVIP"); + System.out.println("=============================="); + System.out.print("번호를 입력해주세요: "); + } + + private int inputGroupNumber() { int groupNumber = 0; while (groupNumber == 0) { try { @@ -27,28 +45,7 @@ public void addData() { System.out.println(e.getMessage()); } } - - //groupNumber to group - GroupType groupType = groupNumberToGroupType(groupNumber); - MyArrayList groupList = groups.getGroups(); - for (Group group : groupList) { - if (group.getCustomerGroup() == groupType) { - if (group.getParameter().getMinimumHours() != 0 || group.getParameter().getMinimumTotalAmount() != 0) { - System.out.println("이미 기준이 등록된 등급입니다."); - return; - }//입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 - int parameterNumber = Integer.parseInt(br.readLine()); - //누적 시간 입력 받음 - if (parameterNumber == 1) { - int hours = Integer.parseInt(br.readLine()); - group.getParameter().setMinimumHours(hours); - return; - } - int totalAmount = Integer.parseInt(br.readLine()); - group.getParameter().setMinimumTotalAmount(totalAmount); - return; - } - } + return groupNumber; } private GroupType groupNumberToGroupType(int groupNumber) { @@ -61,6 +58,33 @@ private GroupType groupNumberToGroupType(int groupNumber) { return GroupType.VVIP; } + private boolean insertParameter(GroupType groupType) { + MyArrayList groupList = groups.getGroups(); + for (Group group : groupList) { + if (group.getCustomerGroup() == groupType) { + //찾은 요소가 이미 입력이 된 경우 return + if (group.getParameter().getMinimumHours() != 0 || group.getParameter().getMinimumTotalAmount() != 0) { + System.out.println("이미 기준이 등록된 등급입니다."); + return false; + }//기준을 입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 + try { + int parameterNumber = Integer.parseInt(br.readLine()); + //누적 시간 입력 받음 + if (parameterNumber == 1) { + int hours = Integer.parseInt(br.readLine()); + group.getParameter().setMinimumHours(hours); + return true; + } + int totalAmount = Integer.parseInt(br.readLine()); + group.getParameter().setMinimumTotalAmount(totalAmount); + return true; + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + } + } + @Override public void viewData() { From c4d278972080283d70a98e25ba4191e40040de7b Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 22:55:06 +0900 Subject: [PATCH 36/73] =?UTF-8?q?refactor(GroupMenu):=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/GroupMenu.java | 69 +++++++++++++------ 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index f4702d64..e429f39f 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -10,10 +10,28 @@ public class GroupMenu extends Menu implements DataCRUD { @Override public void addData() { //변경할 등급 선택 + printGroupSelectionMessage(); + int groupNumber = inputGroupNumber(); + //groupNumber to group + GroupType groupType = groupNumberToGroupType(groupNumber); + //groupList에서 입력받은 등급에 해당하는 요소를 찾음 + if (insertParameter(groupType)) { + System.out.println("기준이 성공적으로 입력되었습니다."); + } + + } + + + private void printGroupSelectionMessage() { System.out.println("다음 등급 중 하나를 선택해주세요."); System.out.println("1. General"); System.out.println("2. VIP"); System.out.println("3. VVIP"); + System.out.println("=============================="); + System.out.print("번호를 입력해주세요: "); + } + + private int inputGroupNumber() { int groupNumber = 0; while (groupNumber == 0) { try { @@ -27,28 +45,7 @@ public void addData() { System.out.println(e.getMessage()); } } - - //groupNumber to group - GroupType groupType = groupNumberToGroupType(groupNumber); - MyArrayList groupList = groups.getGroups(); - for (Group group : groupList) { - if (group.getCustomerGroup() == groupType) { - if (group.getParameter().getMinimumHours() != 0 || group.getParameter().getMinimumTotalAmount() != 0) { - System.out.println("이미 기준이 등록된 등급입니다."); - return; - }//입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 - int parameterNumber = Integer.parseInt(br.readLine()); - //누적 시간 입력 받음 - if (parameterNumber == 1) { - int hours = Integer.parseInt(br.readLine()); - group.getParameter().setMinimumHours(hours); - return; - } - int totalAmount = Integer.parseInt(br.readLine()); - group.getParameter().setMinimumTotalAmount(totalAmount); - return; - } - } + return groupNumber; } private GroupType groupNumberToGroupType(int groupNumber) { @@ -61,6 +58,34 @@ private GroupType groupNumberToGroupType(int groupNumber) { return GroupType.VVIP; } + private boolean insertParameter(GroupType groupType) { + MyArrayList groupList = groups.getGroups(); + for (Group group : groupList) { + if (group.getCustomerGroup() == groupType) { + //찾은 요소가 이미 입력이 된 경우 return + if (group.getParameter().getMinimumHours() != 0 || group.getParameter().getMinimumTotalAmount() != 0) { + System.out.println("이미 기준이 등록된 등급입니다."); + return false; + }//기준을 입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 + try { + int parameterNumber = Integer.parseInt(br.readLine()); + //누적 시간 입력 받음 + if (parameterNumber == 1) { + int hours = Integer.parseInt(br.readLine()); + group.getParameter().setMinimumHours(hours); + return true; + } + int totalAmount = Integer.parseInt(br.readLine()); + group.getParameter().setMinimumTotalAmount(totalAmount); + return true; + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + } + return false; + } + @Override public void viewData() { From 558783e5ae1f00907dcafd4d8b97aeaedf6f44ad Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 22:59:14 +0900 Subject: [PATCH 37/73] =?UTF-8?q?feat(GroupMenu):=20=EA=B3=A0=EA=B0=9D=20?= =?UTF-8?q?=EB=93=B1=EA=B8=89=20=EA=B8=B0=EC=A4=80=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index e429f39f..7ef1a291 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -88,7 +88,16 @@ private boolean insertParameter(GroupType groupType) { @Override public void viewData() { - + printGroupSelectionMessage(); + int groupNumber = inputGroupNumber(); + //groupNumber to group + GroupType groupType = groupNumberToGroupType(groupNumber); + MyArrayList groupList = groups.getGroups(); + for (Group group : groupList) { + if (group.getCustomerGroup() == groupType) { + System.out.println(group.getParameter()); + } + } } @Override From 5a623a5ce5930bdfe89b695356a999df37a694a0 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Wed, 10 May 2023 23:13:17 +0900 Subject: [PATCH 38/73] =?UTF-8?q?refactor(GroupMenu):=20=EA=B2=B9=EC=B9=98?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20updateData()=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/GroupMenu.java | 72 +++++++++++-------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 7ef1a291..6fa6482a 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -3,8 +3,10 @@ import me.smartstore.collections.MyArrayList; import me.smartstore.group.Group; import me.smartstore.group.GroupType; +import me.smartstore.group.Parameter; import java.io.IOException; +import java.util.NoSuchElementException; public class GroupMenu extends Menu implements DataCRUD { @Override @@ -15,9 +17,7 @@ public void addData() { //groupNumber to group GroupType groupType = groupNumberToGroupType(groupNumber); //groupList에서 입력받은 등급에 해당하는 요소를 찾음 - if (insertParameter(groupType)) { - System.out.println("기준이 성공적으로 입력되었습니다."); - } + insert(groupType); } @@ -58,32 +58,42 @@ private GroupType groupNumberToGroupType(int groupNumber) { return GroupType.VVIP; } - private boolean insertParameter(GroupType groupType) { + private void insert(GroupType groupType) { + Parameter parameter = findParameter(groupType); + //찾은 요소가 이미 입력이 된 경우 return + if (parameter.getMinimumHours() != 0 || parameter.getMinimumTotalAmount() != 0) { + System.out.println("이미 기준이 등록된 등급입니다."); + return; + } + insertInputParameter(parameter); + } + + private void insertInputParameter(Parameter parameter) { + //기준을 입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 + try { + int parameterNumber = Integer.parseInt(br.readLine()); + //누적 시간 입력 받음 + if (parameterNumber == 1) { + int hours = Integer.parseInt(br.readLine()); + parameter.setMinimumHours(hours); + return; + } + //누적 결제 금액 입력 받음 + int totalAmount = Integer.parseInt(br.readLine()); + parameter.setMinimumTotalAmount(totalAmount); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + + private Parameter findParameter(GroupType groupType) { MyArrayList groupList = groups.getGroups(); for (Group group : groupList) { if (group.getCustomerGroup() == groupType) { - //찾은 요소가 이미 입력이 된 경우 return - if (group.getParameter().getMinimumHours() != 0 || group.getParameter().getMinimumTotalAmount() != 0) { - System.out.println("이미 기준이 등록된 등급입니다."); - return false; - }//기준을 입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 - try { - int parameterNumber = Integer.parseInt(br.readLine()); - //누적 시간 입력 받음 - if (parameterNumber == 1) { - int hours = Integer.parseInt(br.readLine()); - group.getParameter().setMinimumHours(hours); - return true; - } - int totalAmount = Integer.parseInt(br.readLine()); - group.getParameter().setMinimumTotalAmount(totalAmount); - return true; - } catch (IOException e) { - System.out.println(e.getMessage()); - } + return group.getParameter(); } } - return false; + throw new NoSuchElementException("해당하는 등급이 존재하지 않습니다."); } @Override @@ -92,17 +102,17 @@ public void viewData() { int groupNumber = inputGroupNumber(); //groupNumber to group GroupType groupType = groupNumberToGroupType(groupNumber); - MyArrayList groupList = groups.getGroups(); - for (Group group : groupList) { - if (group.getCustomerGroup() == groupType) { - System.out.println(group.getParameter()); - } - } + Parameter parameter = findParameter(groupType); + System.out.println(parameter); } @Override public void updateData() { - + printGroupSelectionMessage(); + int groupNumber = inputGroupNumber(); + GroupType groupType = groupNumberToGroupType(groupNumber); + Parameter parameter = findParameter(groupType); + insertInputParameter(parameter); } @Override From 00fabe55a1ccfebd5a18be019748f4e4e38a4d63 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 02:01:25 +0900 Subject: [PATCH 39/73] =?UTF-8?q?docs(=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D):=20=EA=B5=AC=ED=98=84=ED=95=9C=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/feature_list.md | 11 +++++------ src/main/java/me/smartstore/menu/GroupMenu.java | 7 ------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/docs/feature_list.md b/docs/feature_list.md index 62d68f47..64573000 100644 --- a/docs/feature_list.md +++ b/docs/feature_list.md @@ -1,12 +1,11 @@ # 기능 목록 -## 콘솔, 파일을 통해 고객 등급(group) 분류 기준 CRUD +## 콘솔, 파일을 통해 고객 등급(group) 분류 기준 CRU 1. [ ] 콘솔 및 파일을 통해 분류 기준 입력 받음 -2. [ ] 분류 기준 설정 -3. [ ] 분류 기준 조회 -3. [ ] 분류 기준 수정 -4. [ ] 분류 기준 삭제 +2. [X] 분류 기준 설정 +3. [X] 분류 기준 조회 +3. [X] 분류 기준 수정 ## 고객 등급 분류 기능 @@ -27,7 +26,7 @@ ## 예외처리 1. [ ] 고객 분류 기준이 추가될 경우 수정된 분류기준에 따라 고객 재분류 가능해야한다. -2. [ ] 고객 정보가 추가될 때, 다음 시나리오에 대한 예외 처리 +2. [X] 고객 정보가 추가될 때, 다음 시나리오에 대한 예외 처리 - 배열의 크기가 부족할 수 있음 - 배열 크기 더블링 (x2, x1.xx) - 기존 배열의 크기가 5 일 경우, 6번째 고객이 들어온다고 가정. diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index c479786b..8f3270d4 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -17,14 +17,7 @@ public void addData() { //groupNumber to group GroupType groupType = groupNumberToGroupType(groupNumber); //groupList에서 입력받은 등급에 해당하는 요소를 찾음 -<<<<<<< HEAD insert(groupType); -======= - if (insertParameter(groupType)) { - System.out.println("기준이 성공적으로 입력되었습니다."); - } ->>>>>>> a8fe309126a711387ba3d3298fce7f1109aa659c - } From 59c908d52440605b4fcbbcc6a6981210f1d220a2 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 17:37:09 +0900 Subject: [PATCH 40/73] =?UTF-8?q?refacor(menu):=20menu=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EB=82=B4=20=EB=AA=A8=EB=93=A0=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=8B=B1=EA=B8=80=ED=86=A4=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/CustomerMenu.java | 12 ++++++++++++ src/main/java/me/smartstore/menu/GroupMenu.java | 12 ++++++++++++ src/main/java/me/smartstore/menu/Menu.java | 15 +++++++++++---- src/main/java/me/smartstore/menu/SummaryMenu.java | 12 ++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index 7902809c..f093f7e0 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -7,6 +7,18 @@ import java.io.IOException; public class CustomerMenu extends Menu implements DataCRUD { + private static CustomerMenu customerMenu; + + private CustomerMenu() { + } + + public static CustomerMenu getInstance() { + if (customerMenu == null) { + customerMenu = new CustomerMenu(); + } + return customerMenu; + } + @Override public void addData() { try { diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 8f3270d4..06839f37 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -9,6 +9,18 @@ import java.util.NoSuchElementException; public class GroupMenu extends Menu implements DataCRUD { + private static GroupMenu groupMenu; + + private GroupMenu() { + } + + public static GroupMenu getInstance() { + if (groupMenu == null) { + groupMenu = new GroupMenu(); + } + return groupMenu; + } + @Override public void addData() { //변경할 등급 선택 diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 2edb0496..960b2625 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -14,13 +14,20 @@ public class Menu { protected Customers customers; protected Groups groups; protected ClassifiedCustomers classifiedCustomers; + private static Menu menu; - //@Todo 여러 객체가 필요없는 객체는 싱글톤으로 변경(Menu포함) - public Menu() { + protected Menu() { br = new BufferedReader(new InputStreamReader(System.in)); customers = Customers.getInstance(); - groups= Groups.getInstance(); - classifiedCustomers=ClassifiedCustomers.getInstance(); + groups = Groups.getInstance(); + classifiedCustomers = ClassifiedCustomers.getInstance(); + } + + public static Menu getInstance() { + if (menu == null) { + menu = new Menu(); + } + return menu; } protected void initMenu() { diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 0fb108ca..aea14335 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -8,6 +8,18 @@ import java.io.IOException; public class SummaryMenu extends Menu { + private static SummaryMenu summaryMenu; + + private SummaryMenu() { + } + + public static SummaryMenu getInstance() { + if (summaryMenu == null) { + summaryMenu = new SummaryMenu(); + } + return summaryMenu; + } + public void summary(OrderType orderType) { classifiedCustomers.refresh(); //@Todo summary메뉴 진입 시 호출하는 걸로 변경 예정 GroupType[] groupTypes = GroupType.values(); From ee16ffac0df875e1034c91a6d6814cdf833da4d4 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 19:58:46 +0900 Subject: [PATCH 41/73] =?UTF-8?q?feat(Runner):=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EB=9E=A8=20=EC=8B=A4=ED=96=89=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/Main.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/me/smartstore/Main.java diff --git a/src/main/java/me/smartstore/Main.java b/src/main/java/me/smartstore/Main.java new file mode 100644 index 00000000..9c20405d --- /dev/null +++ b/src/main/java/me/smartstore/Main.java @@ -0,0 +1,10 @@ +package me.smartstore; + +import me.smartstore.runner.MainRunner; + +public class Main { + public static void main(String[] args) { + MainRunner mainRunner = MainRunner.getInstance(); + mainRunner.run(); + } +} From a9f57ab477db1aef2047c3de54d53c79ddd4bdcc Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 19:59:32 +0900 Subject: [PATCH 42/73] =?UTF-8?q?fixt(Menu):=20=EC=9E=85=EB=A0=A5=EB=B0=9B?= =?UTF-8?q?=EC=9D=80=20menu=EC=9D=98=20=EC=88=AB=EC=9E=90=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/Menu.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 960b2625..5f13d240 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -30,12 +30,13 @@ public static Menu getInstance() { return menu; } - protected void initMenu() { + public int initMenu() { printInitMenu(); int menuNumber = 0; while (menuNumber < 1 || menuNumber > 4) { try { menuNumber = readInt(); + return menuNumber } catch (IOException e) { System.out.println(e.getMessage()); } From 1496a1ccd88412a611b1029ef6d0b449e6e1c1ea Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 20:07:50 +0900 Subject: [PATCH 43/73] =?UTF-8?q?fix(Menu):=20while=EB=AC=B8=20=EB=82=B4?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9E=85=EB=A0=A5=EB=B0=9B=EC=9D=80=20?= =?UTF-8?q?=EB=A9=94=EB=89=B4=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95=20=EB=B0=8F?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/Menu.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 5f13d240..3c302bb9 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -30,17 +30,13 @@ public static Menu getInstance() { return menu; } - public int initMenu() { + public int initMenu() throws IOException { printInitMenu(); int menuNumber = 0; while (menuNumber < 1 || menuNumber > 4) { - try { - menuNumber = readInt(); - return menuNumber - } catch (IOException e) { - System.out.println(e.getMessage()); - } + menuNumber = readInt(); } + return menuNumber; } private void printInitMenu() { From 29a7c3988c801545f527b8cde20ccf4136f9b734 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 20:33:03 +0900 Subject: [PATCH 44/73] =?UTF-8?q?refactor(Menu):=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EB=B2=88=ED=98=B8=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=B0=8F=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/Menu.java | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 3c302bb9..8e081177 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -30,13 +30,9 @@ public static Menu getInstance() { return menu; } - public int initMenu() throws IOException { + public int initMenu() { printInitMenu(); - int menuNumber = 0; - while (menuNumber < 1 || menuNumber > 4) { - menuNumber = readInt(); - } - return menuNumber; + return readNumber(); } private void printInitMenu() { @@ -50,11 +46,21 @@ private void printInitMenu() { } - //@Todo 예외처리 - private int readInt() throws IOException { - String input = br.readLine(); - int newInt = Integer.parseInt(input); - return newInt; + private int readNumber() { + int menuNumber = 0; + while (menuNumber == 0) { + try { + int temp = Integer.parseInt(br.readLine()); + if (temp >= 1 && temp <= 4) { + menuNumber = temp; + } else { + System.out.println("1부터 4까지의 숫자를 입력해주세요."); + } + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + return menuNumber; } protected void back() { From dc66c647fc2b8be8656668edc706e07fb91a8ed3 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 20:35:08 +0900 Subject: [PATCH 45/73] refactor(Menu): initMenu -> inputInitMenuNumber MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 메서드의 기능에 맞게 이름 변경 --- src/main/java/me/smartstore/menu/Menu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 8e081177..def842a7 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -30,7 +30,7 @@ public static Menu getInstance() { return menu; } - public int initMenu() { + public int inputInitMenuNumber() { printInitMenu(); return readNumber(); } From 8cb38a586dfbb798a6365190b7f46f0dc7ed5acc Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 20:38:12 +0900 Subject: [PATCH 46/73] =?UTF-8?q?feat(SummaryMenu):=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EB=B0=9B=EC=9D=80=20=EB=A9=94=EB=89=B4=EB=B2=88=ED=98=B8?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=9A=94=EC=95=BD=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=ED=98=B8=EC=B6=9C=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/SummaryMenu.java | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index aea14335..1cd17a60 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -20,8 +20,42 @@ public static SummaryMenu getInstance() { return summaryMenu; } - public void summary(OrderType orderType) { - classifiedCustomers.refresh(); //@Todo summary메뉴 진입 시 호출하는 걸로 변경 예정 + public void run(){ + classifiedCustomers.refresh(); + printSummaryInitMenu(); + int summaryNumber = inputSummaryNumber(); + if(summaryNumber==1){ + summary(OrderType.NONE); + return; + } + if(summaryNumber==2){ + summarySortByName(); + return; + } + if(summaryNumber==3){ + summarySortByHours(); + return; + } + summarySortByTotalAmount(); + } + + private int inputSummaryNumber(){ + int summaryNumber = 0; + while (summaryNumber == 0) { + try { + int temp = Integer.parseInt(br.readLine()); + if (temp >= 1 && temp <= 5) { + summaryNumber = temp; + } else { + System.out.println("1부터 5까지의 숫자를 입력해주세요."); + } + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + return summaryNumber; + } + private void summary(OrderType orderType) { GroupType[] groupTypes = GroupType.values(); MyArrayList> classifications = classifiedCustomers.getClassifications(); printCustomerSummary(orderType, groupTypes, classifications); @@ -43,20 +77,20 @@ private void printCustomerSummary(OrderType orderType, GroupType[] groupTypes, M System.out.println("=============================="); } - public void summarySortByName() { + private void summarySortByName() { OrderType orderType = inputOrderType(); //등급 기준에 따라 정렬 classifiedCustomers.setSortBy(SortBy.NAME); summary(orderType); } - public void summarySortByHours() { + private void summarySortByHours() { OrderType orderType = inputOrderType(); classifiedCustomers.setSortBy(SortBy.HOURS); summary(orderType); } - public void summarySortByTotalAmount() { + private void summarySortByTotalAmount() { OrderType orderType = inputOrderType(); classifiedCustomers.setSortBy(SortBy.TOTAL_AMOUNT); summary(orderType); From 488e965d5763f938d72d05f15170a22fdd98b90a Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 20:48:15 +0900 Subject: [PATCH 47/73] =?UTF-8?q?refactor(menu):=20=EB=A9=94=EB=89=B4?= =?UTF-8?q?=EB=B2=88=ED=98=B8=EB=A5=BC=20=EC=9E=85=EB=A0=A5=EB=B0=9B?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A5=BC=20=ED=95=98?= =?UTF-8?q?=EB=82=98=EB=A1=9C=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 모든 메뉴 클래스가 메뉴번호를 입력받는 메서드를 구현해야함에 따라 부모클래스에 이를 정의하고 자식클래스에서 오버라이딩하도록 함. --- src/main/java/me/smartstore/menu/GroupMenu.java | 9 +++++---- src/main/java/me/smartstore/menu/Menu.java | 2 +- src/main/java/me/smartstore/menu/SummaryMenu.java | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 06839f37..43e216e2 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -25,7 +25,7 @@ public static GroupMenu getInstance() { public void addData() { //변경할 등급 선택 printGroupSelectionMessage(); - int groupNumber = inputGroupNumber(); + int groupNumber = readNumber(); //groupNumber to group GroupType groupType = groupNumberToGroupType(groupNumber); //groupList에서 입력받은 등급에 해당하는 요소를 찾음 @@ -42,7 +42,8 @@ private void printGroupSelectionMessage() { System.out.print("번호를 입력해주세요: "); } - private int inputGroupNumber() { + @Override + protected int readNumber() { int groupNumber = 0; while (groupNumber == 0) { try { @@ -110,7 +111,7 @@ private Parameter findParameter(GroupType groupType) { @Override public void viewData() { printGroupSelectionMessage(); - int groupNumber = inputGroupNumber(); + int groupNumber = readNumber(); //groupNumber to group GroupType groupType = groupNumberToGroupType(groupNumber); Parameter parameter = findParameter(groupType); @@ -120,7 +121,7 @@ public void viewData() { @Override public void updateData() { printGroupSelectionMessage(); - int groupNumber = inputGroupNumber(); + int groupNumber = readNumber(); GroupType groupType = groupNumberToGroupType(groupNumber); Parameter parameter = findParameter(groupType); insertInputParameter(parameter); diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index def842a7..a55978da 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -46,7 +46,7 @@ private void printInitMenu() { } - private int readNumber() { + protected int readNumber() { int menuNumber = 0; while (menuNumber == 0) { try { diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 1cd17a60..6240d080 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -23,7 +23,7 @@ public static SummaryMenu getInstance() { public void run(){ classifiedCustomers.refresh(); printSummaryInitMenu(); - int summaryNumber = inputSummaryNumber(); + int summaryNumber = readNumber(); if(summaryNumber==1){ summary(OrderType.NONE); return; @@ -39,7 +39,8 @@ public void run(){ summarySortByTotalAmount(); } - private int inputSummaryNumber(){ + @Override + protected int readNumber(){ int summaryNumber = 0; while (summaryNumber == 0) { try { From a152e21d0a5f1cec61f5df2d50a10ebaac689e8c Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 20:58:51 +0900 Subject: [PATCH 48/73] =?UTF-8?q?refactor(menu):=20=EB=AA=A8=EB=93=A0=20?= =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EC=9E=85=EB=A0=A5=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EC=9D=98=20=EA=B8=B0=EB=8A=A5=EC=9D=B4=20=EA=B2=B9?= =?UTF-8?q?=EC=B9=A8=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 여러 클래스에서 사용되는 readNumber()의 구현내용이 숫자의 범위를 제외하고 모두 겹침. 따라서, 부모클래스에서만 해당 메서드를 정의하고 자식메서드는 이를 호출하도록 함. --- .../java/me/smartstore/menu/GroupMenu.java | 25 +++---------------- src/main/java/me/smartstore/menu/Menu.java | 8 +++--- .../java/me/smartstore/menu/SummaryMenu.java | 20 +-------------- 3 files changed, 8 insertions(+), 45 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 43e216e2..11156aa7 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -25,7 +25,7 @@ public static GroupMenu getInstance() { public void addData() { //변경할 등급 선택 printGroupSelectionMessage(); - int groupNumber = readNumber(); + int groupNumber = readNumber(3); //groupNumber to group GroupType groupType = groupNumberToGroupType(groupNumber); //groupList에서 입력받은 등급에 해당하는 요소를 찾음 @@ -41,25 +41,6 @@ private void printGroupSelectionMessage() { System.out.println("=============================="); System.out.print("번호를 입력해주세요: "); } - - @Override - protected int readNumber() { - int groupNumber = 0; - while (groupNumber == 0) { - try { - int temp = Integer.parseInt(br.readLine()); - if (temp >= 1 && temp <= 3) { - groupNumber = temp; - } else { - System.out.println("1부터 3까지의 숫자를 입력해주세요."); - } - } catch (IOException e) { - System.out.println(e.getMessage()); - } - } - return groupNumber; - } - private GroupType groupNumberToGroupType(int groupNumber) { if (groupNumber == 1) { return GroupType.General; @@ -111,7 +92,7 @@ private Parameter findParameter(GroupType groupType) { @Override public void viewData() { printGroupSelectionMessage(); - int groupNumber = readNumber(); + int groupNumber = readNumber(3); //groupNumber to group GroupType groupType = groupNumberToGroupType(groupNumber); Parameter parameter = findParameter(groupType); @@ -121,7 +102,7 @@ public void viewData() { @Override public void updateData() { printGroupSelectionMessage(); - int groupNumber = readNumber(); + int groupNumber = readNumber(3); GroupType groupType = groupNumberToGroupType(groupNumber); Parameter parameter = findParameter(groupType); insertInputParameter(parameter); diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index a55978da..559730ae 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -32,7 +32,7 @@ public static Menu getInstance() { public int inputInitMenuNumber() { printInitMenu(); - return readNumber(); + return readNumber(4); } private void printInitMenu() { @@ -46,15 +46,15 @@ private void printInitMenu() { } - protected int readNumber() { + protected int readNumber(int end) { int menuNumber = 0; while (menuNumber == 0) { try { int temp = Integer.parseInt(br.readLine()); - if (temp >= 1 && temp <= 4) { + if (temp >= 1 && temp <= end) { menuNumber = temp; } else { - System.out.println("1부터 4까지의 숫자를 입력해주세요."); + System.out.printf("1부터 %d까지의 숫자를 입력해주세요.\n", end); } } catch (IOException e) { System.out.println(e.getMessage()); diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 6240d080..0ee0e952 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -23,7 +23,7 @@ public static SummaryMenu getInstance() { public void run(){ classifiedCustomers.refresh(); printSummaryInitMenu(); - int summaryNumber = readNumber(); + int summaryNumber = readNumber(5); if(summaryNumber==1){ summary(OrderType.NONE); return; @@ -38,24 +38,6 @@ public void run(){ } summarySortByTotalAmount(); } - - @Override - protected int readNumber(){ - int summaryNumber = 0; - while (summaryNumber == 0) { - try { - int temp = Integer.parseInt(br.readLine()); - if (temp >= 1 && temp <= 5) { - summaryNumber = temp; - } else { - System.out.println("1부터 5까지의 숫자를 입력해주세요."); - } - } catch (IOException e) { - System.out.println(e.getMessage()); - } - } - return summaryNumber; - } private void summary(OrderType orderType) { GroupType[] groupTypes = GroupType.values(); MyArrayList> classifications = classifiedCustomers.getClassifications(); From 4b073e928de4312f8e4e9ea576ea248b1eaaa140 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 21:05:29 +0900 Subject: [PATCH 49/73] =?UTF-8?q?feat(GroupMenu):=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EB=B0=9B=EC=9D=80=20=EB=A9=94=EB=89=B4=EB=B2=88=ED=98=B8?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=ED=95=98=EB=8F=84=EB=A1=9D=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/GroupMenu.java | 18 +++++++ .../java/me/smartstore/runner/MainRunner.java | 47 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/main/java/me/smartstore/runner/MainRunner.java diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 11156aa7..be6b85ee 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -21,6 +21,24 @@ public static GroupMenu getInstance() { return groupMenu; } + public void run() { + printGroupInitMenu(); + int groupMenu = readNumber(4); + if (groupMenu == 1) { + addData(); + return; + } + if (groupMenu == 2) { + viewData(); + return; + } + if (groupMenu == 3) { + updateData(); + return; + } + + } + @Override public void addData() { //변경할 등급 선택 diff --git a/src/main/java/me/smartstore/runner/MainRunner.java b/src/main/java/me/smartstore/runner/MainRunner.java new file mode 100644 index 00000000..bc62f4b1 --- /dev/null +++ b/src/main/java/me/smartstore/runner/MainRunner.java @@ -0,0 +1,47 @@ +package me.smartstore.runner; + +import me.smartstore.menu.CustomerMenu; +import me.smartstore.menu.GroupMenu; +import me.smartstore.menu.Menu; +import me.smartstore.menu.SummaryMenu; + +import java.io.IOException; + +public class MainRunner { + private static MainRunner mainRunner; + private Menu menu; + private GroupMenu groupMenu; + private CustomerMenu customerMenu; + private SummaryMenu summaryMenu; + + //runner -> GroupMenuRunner, SummaryMenuRunner, CustomerMenuRunner 로 분리 + private MainRunner() { + this.menu = Menu.getInstance(); + this.groupMenu = GroupMenu.getInstance(); + this.summaryMenu = SummaryMenu.getInstance(); + this.customerMenu = CustomerMenu.getInstance(); + } + + public static MainRunner getInstance() { + if (mainRunner == null) { + mainRunner = new MainRunner(); + } + return mainRunner; + } + + public void run() { + int initMenu = menu.inputInitMenuNumber(); + if(initMenu==1){ + //groupMenu + groupMenu.run(); + } else if (initMenu==2) { + //customerMenu + + } else if (initMenu==3) { + //summaryMenu + summaryMenu.run(); + } + return; + } + +} From 46db2cfdd283020b692446d2668f5bf2581fbee4 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 21:14:22 +0900 Subject: [PATCH 50/73] =?UTF-8?q?feat(CustomerMenu):=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EB=B0=9B=EC=9D=80=20=EB=A9=94=EB=89=B4=EB=B2=88=ED=98=B8?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=ED=95=98=EB=8F=84=EB=A1=9D=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/CustomerMenu.java | 21 ++++++++++++++++++- .../java/me/smartstore/runner/MainRunner.java | 13 ++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index f093f7e0..b89ff1ce 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -2,7 +2,6 @@ import me.smartstore.collections.MyArrayList; import me.smartstore.customer.Customer; -import me.smartstore.customer.Customers; import java.io.IOException; @@ -19,6 +18,26 @@ public static CustomerMenu getInstance() { return customerMenu; } + public void run() { + printCustomerInitMenu(); + int customerMenuNumber = readNumber(5); + if (customerMenuNumber == 1) { + addData(); + return; + } + if (customerMenuNumber == 2) { + viewData(); + return; + } + if (customerMenuNumber == 3) { + updateData(); + return; + } + if (customerMenuNumber == 4) { + deleteData(); + } + } + @Override public void addData() { try { diff --git a/src/main/java/me/smartstore/runner/MainRunner.java b/src/main/java/me/smartstore/runner/MainRunner.java index bc62f4b1..c19faed4 100644 --- a/src/main/java/me/smartstore/runner/MainRunner.java +++ b/src/main/java/me/smartstore/runner/MainRunner.java @@ -5,8 +5,6 @@ import me.smartstore.menu.Menu; import me.smartstore.menu.SummaryMenu; -import java.io.IOException; - public class MainRunner { private static MainRunner mainRunner; private Menu menu; @@ -31,14 +29,11 @@ public static MainRunner getInstance() { public void run() { int initMenu = menu.inputInitMenuNumber(); - if(initMenu==1){ - //groupMenu + if (initMenu == 1) { groupMenu.run(); - } else if (initMenu==2) { - //customerMenu - - } else if (initMenu==3) { - //summaryMenu + } else if (initMenu == 2) { + customerMenu.run(); + } else if (initMenu == 3) { summaryMenu.run(); } return; From a2d708e693e3f7b515ff898d49473ab6ba1ca62f Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 21:16:18 +0900 Subject: [PATCH 51/73] =?UTF-8?q?fix(SummaryMenu):=204=EB=BF=90=EB=A7=8C?= =?UTF-8?q?=20=EC=95=84=EB=8B=88=EB=9D=BC=205=EB=A5=BC=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EB=B0=9B=EC=95=98=EC=9D=84=20=EB=95=8C=EB=8F=84=20?= =?UTF-8?q?=EB=88=84=EC=A0=81=20=EA=B8=88=EC=95=A1=20=EC=88=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=EB=90=98=EB=8A=94=20=EC=98=A4=EB=A5=98=EB=A5=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 1 - src/main/java/me/smartstore/menu/SummaryMenu.java | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index be6b85ee..c7544542 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -34,7 +34,6 @@ public void run() { } if (groupMenu == 3) { updateData(); - return; } } diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 0ee0e952..a93904eb 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -20,24 +20,27 @@ public static SummaryMenu getInstance() { return summaryMenu; } - public void run(){ + public void run() { classifiedCustomers.refresh(); printSummaryInitMenu(); int summaryNumber = readNumber(5); - if(summaryNumber==1){ + if (summaryNumber == 1) { summary(OrderType.NONE); return; } - if(summaryNumber==2){ + if (summaryNumber == 2) { summarySortByName(); return; } - if(summaryNumber==3){ + if (summaryNumber == 3) { summarySortByHours(); return; } - summarySortByTotalAmount(); + if (summaryNumber == 4) { + summarySortByTotalAmount(); + } } + private void summary(OrderType orderType) { GroupType[] groupTypes = GroupType.values(); MyArrayList> classifications = classifiedCustomers.getClassifications(); From ba7cad971b678f748395648f1280f863736bf940 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 21:23:39 +0900 Subject: [PATCH 52/73] =?UTF-8?q?feat(MainRunner):=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=EA=B0=80=20=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=A8?= =?UTF-8?q?=EC=9D=84=20=EC=A2=85=EB=A3=8C=ED=95=98=EA=B8=B0=20=EC=A0=84?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=EC=8B=A4=ED=96=89=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=9C=A0=EC=A7=80=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 세부 메뉴에서 뒤로가기에 해당하는 번호를 입력받아도 프로그램이 꺼지지 않도록 while문을 이용해 실행 상태 유지 --- .../java/me/smartstore/runner/MainRunner.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/smartstore/runner/MainRunner.java b/src/main/java/me/smartstore/runner/MainRunner.java index c19faed4..8894dac8 100644 --- a/src/main/java/me/smartstore/runner/MainRunner.java +++ b/src/main/java/me/smartstore/runner/MainRunner.java @@ -28,15 +28,17 @@ public static MainRunner getInstance() { } public void run() { - int initMenu = menu.inputInitMenuNumber(); - if (initMenu == 1) { - groupMenu.run(); - } else if (initMenu == 2) { - customerMenu.run(); - } else if (initMenu == 3) { - summaryMenu.run(); + int initMenu = 0; + while (initMenu != 4) { + initMenu = menu.inputInitMenuNumber(); + if (initMenu == 1) { + groupMenu.run(); + } else if (initMenu == 2) { + customerMenu.run(); + } else if (initMenu == 3) { + summaryMenu.run(); + } } - return; } } From aace774d3ffd418f955f39c8291579aa6df788f2 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 21:24:37 +0900 Subject: [PATCH 53/73] =?UTF-8?q?refactor(menu):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=98=EA=B2=8C=20=EC=84=A0=EC=96=B8=EB=90=9C=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/CustomerMenu.java | 5 ----- src/main/java/me/smartstore/menu/GroupMenu.java | 5 ----- src/main/java/me/smartstore/menu/Menu.java | 4 ---- src/main/java/me/smartstore/menu/SummaryMenu.java | 6 ------ 4 files changed, 20 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index b89ff1ce..5b7b58b7 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -168,11 +168,6 @@ public void deleteData() { customerList.remove(customerNumber); } - @Override - public void back() { - - } - public void printCustomerInitMenu() { System.out.println("=============================="); System.out.println("1. 고객 정보 추가"); diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index c7544542..50d6c0a9 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -130,11 +130,6 @@ public void deleteData() { } - @Override - public void back() { - - } - public void printGroupInitMenu() { System.out.println("=============================="); System.out.println("1. 고객 등급 기준 추가"); diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 559730ae..5e6f8446 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -62,8 +62,4 @@ protected int readNumber(int end) { } return menuNumber; } - - protected void back() { - - } } diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index a93904eb..89600c9e 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -99,12 +99,6 @@ private OrderType inputOrderType() { return OrderType.getOrderType(ascendingNumber); } - - @Override - public void back() { - - } - public void printSummaryInitMenu() { System.out.println("=============================="); System.out.println("1. 고객 정보 요약"); From 3af4da79dbbe434ecdd021955280e6216662eaa2 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 22:16:36 +0900 Subject: [PATCH 54/73] =?UTF-8?q?refactor(CustomerMenu):=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/CustomerMenu.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index 5b7b58b7..0e331284 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -75,15 +75,13 @@ public void viewData() { @Override public void updateData() { - viewData(); //변경할 요소의 index를 입력받음 -> 수정 희망하는 정보 받음 - MyArrayList customerList = customers.getCustomers(); - int listSize = customerList.size(); - if (listSize < 1) { - System.out.println("고객이 존재하지 않습니다."); + viewData(); + MyArrayList customerList = getCustomers(); + if (customerList == null) { return; } - + int listSize = customerList.size(); System.out.print("수정을 희망하는 고객 번호를 입력해주세요"); System.out.print(listSize >= 2 ? "(1~" + listSize + ")" : ""); int customerNumber = 0; @@ -107,6 +105,16 @@ public void updateData() { } } + private MyArrayList getCustomers() { + MyArrayList customerList = customers.getCustomers(); + if (customerList.isEmpty()) { + System.out.println("등록된 고객정보가 존재하지 않습니다."); + //예외발생 vs null리턴? + return null; + } + return customerList; + } + private void printCustomerUpdateMessage() { System.out.println("=============================="); System.out.println("수정할 정보를 선택해주세요"); From 5cead7975e36788f0a328d0dc23350be4ff0c7d4 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 22:17:23 +0900 Subject: [PATCH 55/73] =?UTF-8?q?fix(Customers):=20customers=EC=9D=98=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=EB=A5=BC=20=EC=96=B4=EB=94=94=EC=97=90?= =?UTF-8?q?=EC=84=9C=EB=8F=84=20=EC=83=9D=EC=84=B1=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=95=84=20=EB=82=98=EB=8D=98=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=EB=A5=BC=20=EA=B3=A0=EC=B9=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/customer/Customers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/customer/Customers.java b/src/main/java/me/smartstore/customer/Customers.java index 431b9ca1..1f9f258d 100644 --- a/src/main/java/me/smartstore/customer/Customers.java +++ b/src/main/java/me/smartstore/customer/Customers.java @@ -6,7 +6,7 @@ public class Customers { private static Customers instance; - private MyArrayList customers; + private final MyArrayList customers = new MyArrayList<>(); private Customers(){} public static Customers getInstance() { From df872389f4c5d9bef9747202ea2bd35d5edd8f2a Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Fri, 12 May 2023 22:34:01 +0900 Subject: [PATCH 56/73] =?UTF-8?q?feat(menu):=20=EA=B0=81=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=EB=A9=94=EB=89=B4=EC=97=90=EC=84=9C=20=EB=92=A4?= =?UTF-8?q?=EB=A1=9C=EA=B0=80=EA=B8=B0=EB=A5=BC=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EB=B0=9B=EA=B8=B0=20=EC=A0=84=EA=B9=8C=EC=A7=80=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=20=EB=A9=94=EB=89=B4=EB=A5=BC=20=EC=9C=A0=EC=A7=80?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/menu/CustomerMenu.java | 29 +++++++++---------- .../java/me/smartstore/menu/GroupMenu.java | 25 ++++++++-------- .../java/me/smartstore/menu/SummaryMenu.java | 29 +++++++++---------- 3 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index 0e331284..aacad85f 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -19,22 +19,19 @@ public static CustomerMenu getInstance() { } public void run() { - printCustomerInitMenu(); - int customerMenuNumber = readNumber(5); - if (customerMenuNumber == 1) { - addData(); - return; - } - if (customerMenuNumber == 2) { - viewData(); - return; - } - if (customerMenuNumber == 3) { - updateData(); - return; - } - if (customerMenuNumber == 4) { - deleteData(); + int customerMenuNumber = 0; + while (customerMenuNumber != 5) { + printCustomerInitMenu(); + customerMenuNumber = readNumber(5); + if (customerMenuNumber == 1) { + addData(); + } else if (customerMenuNumber == 2) { + viewData(); + } else if (customerMenuNumber == 3) { + updateData(); + } else if (customerMenuNumber == 4) { + deleteData(); + } } } diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 50d6c0a9..08ab94dd 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -22,20 +22,18 @@ public static GroupMenu getInstance() { } public void run() { - printGroupInitMenu(); - int groupMenu = readNumber(4); - if (groupMenu == 1) { - addData(); - return; - } - if (groupMenu == 2) { - viewData(); - return; - } - if (groupMenu == 3) { - updateData(); + int groupMenu = 0; + while (groupMenu != 4) { + groupMenu = readNumber(4); + printGroupInitMenu(); + if (groupMenu == 1) { + addData(); + } else if (groupMenu == 2) { + viewData(); + } else if (groupMenu == 3) { + updateData(); + } } - } @Override @@ -58,6 +56,7 @@ private void printGroupSelectionMessage() { System.out.println("=============================="); System.out.print("번호를 입력해주세요: "); } + private GroupType groupNumberToGroupType(int groupNumber) { if (groupNumber == 1) { return GroupType.General; diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 89600c9e..95954a2c 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -22,22 +22,19 @@ public static SummaryMenu getInstance() { public void run() { classifiedCustomers.refresh(); - printSummaryInitMenu(); - int summaryNumber = readNumber(5); - if (summaryNumber == 1) { - summary(OrderType.NONE); - return; - } - if (summaryNumber == 2) { - summarySortByName(); - return; - } - if (summaryNumber == 3) { - summarySortByHours(); - return; - } - if (summaryNumber == 4) { - summarySortByTotalAmount(); + int summaryNumber = 0; + while (summaryNumber != 5) { + summaryNumber = readNumber(5); + printSummaryInitMenu(); + if (summaryNumber == 1) { + summary(OrderType.NONE); + } else if (summaryNumber == 2) { + summarySortByName(); + } else if (summaryNumber == 3) { + summarySortByHours(); + } else if (summaryNumber == 4) { + summarySortByTotalAmount(); + } } } From 9ceae4f0bb761e81666a8148f6923ad4a15453d3 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Sun, 14 May 2023 18:24:03 +0900 Subject: [PATCH 57/73] =?UTF-8?q?fix(Groups):groups=EA=B0=9D=EC=B2=B4?= =?UTF-8?q?=EB=A5=BC=20=EC=96=B4=EB=94=94=EC=97=90=EC=84=9C=EB=8F=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=ED=95=98=EC=A7=80=20=EC=95=8A=EC=95=84=20?= =?UTF-8?q?=EB=82=98=EB=8D=98=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/group/Groups.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/group/Groups.java b/src/main/java/me/smartstore/group/Groups.java index 3520d0ba..b3b62ca5 100644 --- a/src/main/java/me/smartstore/group/Groups.java +++ b/src/main/java/me/smartstore/group/Groups.java @@ -3,7 +3,7 @@ import me.smartstore.collections.MyArrayList; public class Groups { - private MyArrayList groups; + private MyArrayList groups = new MyArrayList<>(); private static Groups instance; private Groups() { From d144cc3f2ff3b3fd9a8db46a040c704fc97c041c Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Sun, 14 May 2023 18:28:21 +0900 Subject: [PATCH 58/73] =?UTF-8?q?feat(GroupMenu):=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=EB=90=9C=20=EB=93=B1=EA=B8=89=20=EA=B8=B0=EC=A4=80=EC=9D=B4=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=20=EC=98=88=EC=99=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 08ab94dd..67f8ebeb 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -24,8 +24,8 @@ public static GroupMenu getInstance() { public void run() { int groupMenu = 0; while (groupMenu != 4) { - groupMenu = readNumber(4); printGroupInitMenu(); + groupMenu = readNumber(4); if (groupMenu == 1) { addData(); } else if (groupMenu == 2) { @@ -97,6 +97,9 @@ private void insertInputParameter(Parameter parameter) { private Parameter findParameter(GroupType groupType) { MyArrayList groupList = groups.getGroups(); + if (groupList.isEmpty()) { + throw new NullPointerException("등록된 등급 기준이 존재하지 않습니다"); + } for (Group group : groupList) { if (group.getCustomerGroup() == groupType) { return group.getParameter(); From 9c24857109a776839ab961ad085afe15e8f82560 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 15:44:31 +0900 Subject: [PATCH 59/73] =?UTF-8?q?docs(=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D):=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/feature_list.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/feature_list.md b/docs/feature_list.md index 64573000..46ad480e 100644 --- a/docs/feature_list.md +++ b/docs/feature_list.md @@ -36,4 +36,6 @@ 3. [ ] 고객 정보가 추가될 때, 다음 시나리오에 대한 예외 처리 - 배열 구멍 뚫리면 안됨 - 0, 1, 2: null, 3, 4 ⇒ 0, 1, 2, 3, 4: null -[ ] 배열의 저장범위를 벗어나게 되면 생기는 예외 처리 \ No newline at end of file +4. [ ] 배열의 저장범위를 벗어나게 되면 생기는 예외 처리 +5. [ ] 상황에 알맞는 사용자 정의 예외 클래스 만들기 + \ No newline at end of file From 878a549c2dbb9581791f9fa33a747538bd7f3136 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 16:09:03 +0900 Subject: [PATCH 60/73] =?UTF-8?q?refactor:=20CustomerMenu=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=EC=97=90=20=EB=93=B1=EB=A1=9D=EB=90=9C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=EA=B0=80=20=EC=A1=B4=EC=9E=AC?= =?UTF-8?q?=ED=95=98=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A5=BC=20Validator?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=EC=9D=98=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 여러 메뉴에서 같은 기능을 사용함에 따라 검증기능을 수행하는 클래스를 만들고 그 클래스 내 정의된 메서드를 사용하도록 함. --- .../java/me/smartstore/menu/CustomerMenu.java | 4 ++- src/main/java/me/smartstore/menu/Menu.java | 4 ++- .../java/me/smartstore/menu/SummaryMenu.java | 3 +++ .../java/me/smartstore/menu/Validator.java | 27 +++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/smartstore/menu/Validator.java diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index aacad85f..74e2b76d 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -61,9 +61,11 @@ private Customer inputCustomerData() throws IOException { return new Customer(name, id, hour, totalAmount); } - @Override public void viewData() { + if (validator.isCustomerListEmpty()) { + return; + } MyArrayList customerList = customers.getCustomers(); for (Customer customer : customerList) { System.out.println(customer); diff --git a/src/main/java/me/smartstore/menu/Menu.java b/src/main/java/me/smartstore/menu/Menu.java index 5e6f8446..e5ad5d73 100644 --- a/src/main/java/me/smartstore/menu/Menu.java +++ b/src/main/java/me/smartstore/menu/Menu.java @@ -10,17 +10,19 @@ import java.io.InputStreamReader; public class Menu { + private static Menu menu; protected BufferedReader br; protected Customers customers; protected Groups groups; protected ClassifiedCustomers classifiedCustomers; - private static Menu menu; + protected Validator validator; protected Menu() { br = new BufferedReader(new InputStreamReader(System.in)); customers = Customers.getInstance(); groups = Groups.getInstance(); classifiedCustomers = ClassifiedCustomers.getInstance(); + validator = Validator.getInstance(); } public static Menu getInstance() { diff --git a/src/main/java/me/smartstore/menu/SummaryMenu.java b/src/main/java/me/smartstore/menu/SummaryMenu.java index 95954a2c..9899e126 100644 --- a/src/main/java/me/smartstore/menu/SummaryMenu.java +++ b/src/main/java/me/smartstore/menu/SummaryMenu.java @@ -21,6 +21,9 @@ public static SummaryMenu getInstance() { } public void run() { + if (validator.isCustomerListEmpty()) { + return; + } classifiedCustomers.refresh(); int summaryNumber = 0; while (summaryNumber != 5) { diff --git a/src/main/java/me/smartstore/menu/Validator.java b/src/main/java/me/smartstore/menu/Validator.java new file mode 100644 index 00000000..069c8ae1 --- /dev/null +++ b/src/main/java/me/smartstore/menu/Validator.java @@ -0,0 +1,27 @@ +package me.smartstore.menu; + +import me.smartstore.collections.MyArrayList; +import me.smartstore.customer.Customer; +import me.smartstore.customer.Customers; + +public class Validator { + private static Validator validator; + private Customers customers; + + private Validator() { + customers = Customers.getInstance(); + } + + public static Validator getInstance() { + if (validator == null) { + validator = new Validator(); + } + return validator; + } + + public boolean isCustomerListEmpty() { + MyArrayList customerList = customers.getCustomers(); + System.out.println("등록된 고객 정보가 존재하지 않습니다."); + return customerList.isEmpty(); + } +} From d4e76016023cf3cfab4b1442838e00fa8e336d29 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 16:13:50 +0900 Subject: [PATCH 61/73] =?UTF-8?q?refactor:=20GroupMenu=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=EC=97=90=20=EB=93=B1=EB=A1=9D=EB=90=9C=20=EB=93=B1?= =?UTF-8?q?=EA=B8=89=20=EA=B8=B0=EC=A4=80=EC=9D=B4=20=EC=A1=B4=EC=9E=AC?= =?UTF-8?q?=ED=95=98=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A5=BC=20Validator?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=EC=9D=98=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 6 +++--- src/main/java/me/smartstore/menu/Validator.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 67f8ebeb..c9ffee56 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -96,10 +96,10 @@ private void insertInputParameter(Parameter parameter) { } private Parameter findParameter(GroupType groupType) { - MyArrayList groupList = groups.getGroups(); - if (groupList.isEmpty()) { - throw new NullPointerException("등록된 등급 기준이 존재하지 않습니다"); + if(validator.isGroupListEmpty()){ + return null; } + MyArrayList groupList = groups.getGroups(); for (Group group : groupList) { if (group.getCustomerGroup() == groupType) { return group.getParameter(); diff --git a/src/main/java/me/smartstore/menu/Validator.java b/src/main/java/me/smartstore/menu/Validator.java index 069c8ae1..73fe4752 100644 --- a/src/main/java/me/smartstore/menu/Validator.java +++ b/src/main/java/me/smartstore/menu/Validator.java @@ -3,13 +3,17 @@ import me.smartstore.collections.MyArrayList; import me.smartstore.customer.Customer; import me.smartstore.customer.Customers; +import me.smartstore.group.Group; +import me.smartstore.group.Groups; public class Validator { private static Validator validator; private Customers customers; + private Groups groups; private Validator() { customers = Customers.getInstance(); + groups = Groups.getInstance(); } public static Validator getInstance() { @@ -24,4 +28,13 @@ public boolean isCustomerListEmpty() { System.out.println("등록된 고객 정보가 존재하지 않습니다."); return customerList.isEmpty(); } + + public boolean isGroupListEmpty() { + MyArrayList groupList = groups.getGroups(); + if (groupList.isEmpty()) { + System.out.println("등록된 등급 기준이 존재하지 않습니다"); + return true; + } + return false; + } } From ba0998755de2cf54fa455fe792c25da5729dcc2b Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 16:15:06 +0900 Subject: [PATCH 62/73] =?UTF-8?q?fix(Validator):=20=EB=B9=88=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EA=B0=80=20=EC=95=84=EB=8B=8C=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=EC=97=90=EB=8F=84=20=EB=B9=84=EC=97=88=EC=9D=8C?= =?UTF-8?q?=EC=9D=84=20=EC=B6=9C=EB=A0=A5=ED=95=98=EB=8D=98=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EB=A5=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/Validator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/smartstore/menu/Validator.java b/src/main/java/me/smartstore/menu/Validator.java index 73fe4752..88bd41a5 100644 --- a/src/main/java/me/smartstore/menu/Validator.java +++ b/src/main/java/me/smartstore/menu/Validator.java @@ -25,8 +25,11 @@ public static Validator getInstance() { public boolean isCustomerListEmpty() { MyArrayList customerList = customers.getCustomers(); - System.out.println("등록된 고객 정보가 존재하지 않습니다."); - return customerList.isEmpty(); + if (customerList.isEmpty()) { + System.out.println("등록된 고객 정보가 존재하지 않습니다."); + return true; + } + return false; } public boolean isGroupListEmpty() { From 89734f59fbc4ee7685999dc7f7b09e2dd5e38672 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 17:31:43 +0900 Subject: [PATCH 63/73] =?UTF-8?q?feat(group):=20Groups=EA=B0=9D=EC=B2=B4?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=ED=95=84=EB=93=9C=20groups?= =?UTF-8?q?=EC=9D=98=20=EC=B4=88=EA=B8=B0=EA=B0=92=EC=9D=84=20=EC=A3=BC?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/group/Groups.java | 3 +++ src/main/java/me/smartstore/group/Parameter.java | 1 + 2 files changed, 4 insertions(+) diff --git a/src/main/java/me/smartstore/group/Groups.java b/src/main/java/me/smartstore/group/Groups.java index b3b62ca5..af96ac95 100644 --- a/src/main/java/me/smartstore/group/Groups.java +++ b/src/main/java/me/smartstore/group/Groups.java @@ -7,6 +7,9 @@ public class Groups { private static Groups instance; private Groups() { + groups.add(new Group(GroupType.General, new Parameter())); + groups.add(new Group(GroupType.VIP, new Parameter())); + groups.add(new Group(GroupType.VVIP, new Parameter())); } public static Groups getInstance() { diff --git a/src/main/java/me/smartstore/group/Parameter.java b/src/main/java/me/smartstore/group/Parameter.java index 5e76ba01..bef13bd5 100644 --- a/src/main/java/me/smartstore/group/Parameter.java +++ b/src/main/java/me/smartstore/group/Parameter.java @@ -4,6 +4,7 @@ public class Parameter { private int minimumHours; private int minimumTotalAmount; + public Parameter(){} public Parameter(int minimumHours, int minimumTotalAmount) { this.minimumHours = minimumHours; this.minimumTotalAmount = minimumTotalAmount; From 26a4618255a4181dc0b828cd57b1f67f34cd4397 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 17:36:08 +0900 Subject: [PATCH 64/73] =?UTF-8?q?fix(menu):=20=ED=96=A5=EC=83=81=EB=90=9C?= =?UTF-8?q?=20for=EB=AC=B8=20=EA=B5=AC=EB=AC=B8=EC=9D=84=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20for=EB=AC=B8=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MyArrayList에 Iterable이 아직 구현되지 않아 당장 향상된 for문을 사용할 수 없어 변경함. --- src/main/java/me/smartstore/menu/CustomerMenu.java | 4 ++-- src/main/java/me/smartstore/menu/GroupMenu.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index 74e2b76d..e7837e1e 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -67,8 +67,8 @@ public void viewData() { return; } MyArrayList customerList = customers.getCustomers(); - for (Customer customer : customerList) { - System.out.println(customer); + for (int i = 0; i < customerList.size(); i++) { + System.out.println(customerList.get(i)); } } diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index c9ffee56..8e59acda 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -100,9 +100,9 @@ private Parameter findParameter(GroupType groupType) { return null; } MyArrayList groupList = groups.getGroups(); - for (Group group : groupList) { - if (group.getCustomerGroup() == groupType) { - return group.getParameter(); + for(int i=0; i Date: Mon, 15 May 2023 17:43:48 +0900 Subject: [PATCH 65/73] =?UTF-8?q?fix(GroupMenu):=20=EA=B8=B0=EC=A4=80=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=20=EC=8B=9C=20=EC=BD=98=EC=86=94=EC=97=90=20?= =?UTF-8?q?=EC=95=8C=EB=A7=9E=EC=9D=80=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=B6=9C=EB=A0=A5=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 8e59acda..56ea7ab3 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -80,14 +80,17 @@ private void insert(GroupType groupType) { private void insertInputParameter(Parameter parameter) { //기준을 입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 try { + printInsertParameterMessage(); int parameterNumber = Integer.parseInt(br.readLine()); //누적 시간 입력 받음 if (parameterNumber == 1) { + System.out.println("누적 이용 시간을 입력해주세요."); int hours = Integer.parseInt(br.readLine()); parameter.setMinimumHours(hours); return; } //누적 결제 금액 입력 받음 + System.out.println("누적 결제 금액을 입력해주세요."); int totalAmount = Integer.parseInt(br.readLine()); parameter.setMinimumTotalAmount(totalAmount); } catch (IOException e) { @@ -95,12 +98,20 @@ private void insertInputParameter(Parameter parameter) { } } + private void printInsertParameterMessage(){ + System.out.println("=============================="); + System.out.println("다음 중 입력할 기준을 선택해주세요."); + System.out.println("1. 누적 이용 시간"); + System.out.println("2. 누적 결제 금액"); + System.out.println("=============================="); + } + private Parameter findParameter(GroupType groupType) { - if(validator.isGroupListEmpty()){ + if (validator.isGroupListEmpty()) { return null; } MyArrayList groupList = groups.getGroups(); - for(int i=0; i Date: Mon, 15 May 2023 17:49:03 +0900 Subject: [PATCH 66/73] =?UTF-8?q?fix(GroupMenu):=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=EA=B0=80=20=EC=9B=90=ED=95=A0=20=EB=95=8C=EA=B9=8C?= =?UTF-8?q?=EC=A7=80=20=EB=A9=94=EB=89=B4=EB=A5=BC=20=EC=A2=85=EB=A3=8C?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 등급 기준을 입력받을 때 누적 이용 시간, 누적 결제 금액 중 하나만 입력되더라도 메인메뉴로 나가는 오류를 수정함. --- src/main/java/me/smartstore/menu/GroupMenu.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 56ea7ab3..3c84ce1f 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -87,22 +87,26 @@ private void insertInputParameter(Parameter parameter) { System.out.println("누적 이용 시간을 입력해주세요."); int hours = Integer.parseInt(br.readLine()); parameter.setMinimumHours(hours); + } else if (parameterNumber == 2) { + //누적 결제 금액 입력 받음 + System.out.println("누적 결제 금액을 입력해주세요."); + int totalAmount = Integer.parseInt(br.readLine()); + parameter.setMinimumTotalAmount(totalAmount); + } else { return; } - //누적 결제 금액 입력 받음 - System.out.println("누적 결제 금액을 입력해주세요."); - int totalAmount = Integer.parseInt(br.readLine()); - parameter.setMinimumTotalAmount(totalAmount); + insertInputParameter(parameter); } catch (IOException e) { System.out.println(e.getMessage()); } } - private void printInsertParameterMessage(){ + private void printInsertParameterMessage() { System.out.println("=============================="); System.out.println("다음 중 입력할 기준을 선택해주세요."); System.out.println("1. 누적 이용 시간"); System.out.println("2. 누적 결제 금액"); + System.out.println("3. 뒤로 가기"); System.out.println("=============================="); } From 081dbcc113d017d725b24262b7a326a0b0dc2213 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 17:56:46 +0900 Subject: [PATCH 67/73] =?UTF-8?q?refactor(GroupMenu):=20=EC=A7=81=EC=A0=91?= =?UTF-8?q?=20=EB=A9=94=EB=89=B4=EB=B2=88=ED=98=B8=EB=A5=BC=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EB=B0=9B=EB=8A=94=20=EB=8C=80=EC=8B=A0=20=EB=B6=80?= =?UTF-8?q?=EB=AA=A8=ED=81=B4=EB=9E=98=EC=8A=A4=20Menu=EC=97=90=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98=EB=90=9C=20readNumber=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20=ED=98=B8=EC=B6=9C=ED=95=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/smartstore/menu/GroupMenu.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 3c84ce1f..497ad7ac 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -79,9 +79,9 @@ private void insert(GroupType groupType) { private void insertInputParameter(Parameter parameter) { //기준을 입력할 메뉴 입력 1: 누적 시간/ 2: 누적 결제 금액 + printInsertParameterMessage(); + int parameterNumber = readNumber(3); try { - printInsertParameterMessage(); - int parameterNumber = Integer.parseInt(br.readLine()); //누적 시간 입력 받음 if (parameterNumber == 1) { System.out.println("누적 이용 시간을 입력해주세요."); @@ -95,6 +95,7 @@ private void insertInputParameter(Parameter parameter) { } else { return; } + //3이 입력되기 전까지 재귀 호출해서 메뉴 실행 상태 유지 insertInputParameter(parameter); } catch (IOException e) { System.out.println(e.getMessage()); From dfc09db860989fab511d08e9ab370d084f9b6d50 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 18:03:06 +0900 Subject: [PATCH 68/73] =?UTF-8?q?fix(Customer):=20=ED=96=A5=EC=83=81?= =?UTF-8?q?=EB=90=9C=20for=EB=AC=B8=20=EA=B5=AC=EB=AC=B8=EC=9D=84=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20for=EB=AC=B8=EC=9C=BC=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MyArrayList에 Iterable이 아직 구현되지 않아 당장 향상된 for문을 사용할 수 없어 변경함. --- src/main/java/me/smartstore/customer/Customer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/smartstore/customer/Customer.java b/src/main/java/me/smartstore/customer/Customer.java index 55499d13..ebd8d656 100644 --- a/src/main/java/me/smartstore/customer/Customer.java +++ b/src/main/java/me/smartstore/customer/Customer.java @@ -28,11 +28,11 @@ private GroupType judgeCustomerGroup(int hours, int totalAmount) { //정렬된 groups요소를 돌며 그 요소의 기준 미만이라면 그 grouptype으로 설정 Groups groups = Groups.getInstance(); MyArrayList groupList = groups.getGroups(); - for (Group group : groupList) { - int minimumHours = group.getParameter().getMinimumHours(); - int minimumTotalAmount = group.getParameter().getMinimumTotalAmount(); + for (int i = 0; i < groupList.size(); i++) { + int minimumHours = groupList.get(i).getParameter().getMinimumHours(); + int minimumTotalAmount = groupList.get(i).getParameter().getMinimumTotalAmount(); if (hours < minimumHours || totalAmount < minimumTotalAmount) { - return group.getCustomerGroup(); + return groupList.get(i).getCustomerGroup(); } } return GroupType.VVIP; From 1b792268ce343b6f859d886e8a0307f27f31599c Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 21:56:40 +0900 Subject: [PATCH 69/73] =?UTF-8?q?feat:=20=EB=93=B1=EA=B8=89=20=EA=B8=B0?= =?UTF-8?q?=EC=A4=80=20=EC=8B=A0=EA=B7=9C=20=EC=83=9D=EC=84=B1=20=EB=B0=8F?= =?UTF-8?q?=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=8B=9C=20=EA=B7=B8?= =?UTF-8?q?=20=EA=B8=B0=EC=A4=80=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EA=B3=A0?= =?UTF-8?q?=EA=B0=9D=20=EB=93=B1=EA=B8=89=20=ED=95=84=EB=93=9C=EA=B0=80=20?= =?UTF-8?q?=EB=B3=80=ED=95=98=EB=8F=84=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/smartstore/customer/Customers.java | 31 +++++++++++++++++-- .../java/me/smartstore/group/GroupType.java | 10 ++++-- .../java/me/smartstore/menu/GroupMenu.java | 3 ++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/smartstore/customer/Customers.java b/src/main/java/me/smartstore/customer/Customers.java index 1f9f258d..cfdd8ea6 100644 --- a/src/main/java/me/smartstore/customer/Customers.java +++ b/src/main/java/me/smartstore/customer/Customers.java @@ -1,14 +1,21 @@ package me.smartstore.customer; import me.smartstore.collections.MyArrayList; +import me.smartstore.group.Group; +import me.smartstore.group.GroupType; +import me.smartstore.group.Groups; import java.util.Arrays; public class Customers { private static Customers instance; + private Groups groups; private final MyArrayList customers = new MyArrayList<>(); - private Customers(){} + private Customers() { + groups = Groups.getInstance(); + } + public static Customers getInstance() { if (instance == null) { instance = new Customers(); @@ -16,7 +23,27 @@ public static Customers getInstance() { return instance; } - public MyArrayList getCustomers() { + public void refreshCustomersGroup() { + MyArrayList groupList = groups.getGroups(); + + for (int i = 0; i < customers.size(); i++) { + Customer currentCustomer = customers.get(i); + int hours = currentCustomer.getHours(); + int totalAmount = currentCustomer.getTotalAmount(); + + for (int j = 0; j < groupList.size(); j++) { + int minimumHours = groupList.get(i).getParameter().getMinimumHours(); + int minimumTotalAmount = groupList.get(i).getParameter().getMinimumTotalAmount(); + if (hours < minimumHours || totalAmount < minimumTotalAmount) { + currentCustomer.setGroup(GroupType.getGroupType(i)); + return; + } + } + currentCustomer.setGroup(GroupType.VVIP); + } + } + + public MyArrayList getCustomers() { return customers; } diff --git a/src/main/java/me/smartstore/group/GroupType.java b/src/main/java/me/smartstore/group/GroupType.java index 88827b1d..fc47dc9e 100644 --- a/src/main/java/me/smartstore/group/GroupType.java +++ b/src/main/java/me/smartstore/group/GroupType.java @@ -3,5 +3,11 @@ public enum GroupType { General, VIP, - VVIP -} + VVIP; + + private static final GroupType[] groupTypes = GroupType.values(); + + public static GroupType getGroupType(int i) { + return groupTypes[i]; + } +} \ No newline at end of file diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 497ad7ac..96aae82e 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -1,6 +1,7 @@ package me.smartstore.menu; import me.smartstore.collections.MyArrayList; +import me.smartstore.customer.Customer; import me.smartstore.group.Group; import me.smartstore.group.GroupType; import me.smartstore.group.Parameter; @@ -87,12 +88,14 @@ private void insertInputParameter(Parameter parameter) { System.out.println("누적 이용 시간을 입력해주세요."); int hours = Integer.parseInt(br.readLine()); parameter.setMinimumHours(hours); + } else if (parameterNumber == 2) { //누적 결제 금액 입력 받음 System.out.println("누적 결제 금액을 입력해주세요."); int totalAmount = Integer.parseInt(br.readLine()); parameter.setMinimumTotalAmount(totalAmount); } else { + customers.refreshCustomersGroup(); return; } //3이 입력되기 전까지 재귀 호출해서 메뉴 실행 상태 유지 From da5300ca3bf3555ab242340fb0317fdd78802fa9 Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 23:19:57 +0900 Subject: [PATCH 70/73] =?UTF-8?q?fix(CustomerMenu):=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20=EB=B0=8F=20=EC=82=AD=EC=A0=9C=20=EC=8B=9C=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=ED=95=9C=20=EC=9C=A0=EC=A0=80=EB=B3=B4=EB=8B=A4=20?= =?UTF-8?q?=ED=95=9C=EB=8B=A8=EA=B3=84=20=EC=9D=B4=EC=A0=84=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EA=B0=80=20=EC=84=A0=ED=83=9D=EB=90=98=EB=8D=98=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=EB=A5=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 번호는 1부터 받았지만 이를 직접적으로 사용해 인덱스로 사용하던 것을 -1 해주어 고침 --- .../java/me/smartstore/menu/CustomerMenu.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/java/me/smartstore/menu/CustomerMenu.java b/src/main/java/me/smartstore/menu/CustomerMenu.java index e7837e1e..26b5fc0c 100644 --- a/src/main/java/me/smartstore/menu/CustomerMenu.java +++ b/src/main/java/me/smartstore/menu/CustomerMenu.java @@ -83,13 +83,7 @@ public void updateData() { int listSize = customerList.size(); System.out.print("수정을 희망하는 고객 번호를 입력해주세요"); System.out.print(listSize >= 2 ? "(1~" + listSize + ")" : ""); - int customerNumber = 0; - try { - customerNumber = Integer.parseInt(br.readLine()); - } catch (IOException e) { - System.out.println(e.getMessage()); - //@Todo: 숫자 입력 받는 부분에서 문자열 등 입력 시 날 수 있는 예외 테스트로 파악, 예외처리 할 것. - } + int customerNumber = readNumber(listSize); printCustomerUpdateMessage(); int updateMenuNumber = 0; @@ -128,7 +122,7 @@ private void printCustomerUpdateMessage() { private void inputNewData(int updateMenuNumber, int customerNumber) throws IOException { MyArrayList customerList = customers.getCustomers(); - Customer customer = customerList.get(customerNumber); + Customer customer = customerList.get(customerNumber - 1); if (updateMenuNumber == 1) { System.out.println("새로운 이름을 입력해주세요."); @@ -165,13 +159,7 @@ public void deleteData() { //@Todo 뒤로가기 추가 System.out.print("삭제할 고객 번호를 입력해주세요"); System.out.print(listSize >= 2 ? "(1~" + listSize + ")" : ""); - int customerNumber = 0; - try { - customerNumber = Integer.parseInt(br.readLine()); - } catch (IOException e) { - System.out.println(e.getMessage()); - //@Todo: 숫자 입력 받는 부분에서 문자열 등 입력 시 날 수 있는 예외 테스트로 파악, 예외처리 할 것. - } + int customerNumber = readNumber(listSize); customerList.remove(customerNumber); } From 28e03b940686b8ac06312f7b2d698d1e4b878cdd Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 23:33:12 +0900 Subject: [PATCH 71/73] =?UTF-8?q?typo(GroupType):=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=20=EB=A3=B0=EC=97=90=20=EB=A7=9E=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8D=98=20=EC=83=81=EC=88=98=EB=AA=85=EC=9D=84=20=EC=98=AC?= =?UTF-8?q?=EB=B0=94=EB=A5=B4=EA=B2=8C=20=EC=88=98=EC=A0=95=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/customer/ClassifiedCustomers.java | 2 +- src/main/java/me/smartstore/group/GroupType.java | 2 +- src/main/java/me/smartstore/group/Groups.java | 2 +- src/main/java/me/smartstore/menu/GroupMenu.java | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/smartstore/customer/ClassifiedCustomers.java b/src/main/java/me/smartstore/customer/ClassifiedCustomers.java index 3cd647dc..02002bd6 100644 --- a/src/main/java/me/smartstore/customer/ClassifiedCustomers.java +++ b/src/main/java/me/smartstore/customer/ClassifiedCustomers.java @@ -27,7 +27,7 @@ public void refresh() { initCustomerList(); for (Customer customer : customerList) { - if (customer.getGroup() == GroupType.General) { + if (customer.getGroup() == GroupType.GENERAL) { classifiedByGeneral.add(customer); continue; } diff --git a/src/main/java/me/smartstore/group/GroupType.java b/src/main/java/me/smartstore/group/GroupType.java index fc47dc9e..3b6db59a 100644 --- a/src/main/java/me/smartstore/group/GroupType.java +++ b/src/main/java/me/smartstore/group/GroupType.java @@ -1,7 +1,7 @@ package me.smartstore.group; public enum GroupType { - General, + GENERAL, VIP, VVIP; diff --git a/src/main/java/me/smartstore/group/Groups.java b/src/main/java/me/smartstore/group/Groups.java index af96ac95..65f3ed24 100644 --- a/src/main/java/me/smartstore/group/Groups.java +++ b/src/main/java/me/smartstore/group/Groups.java @@ -7,7 +7,7 @@ public class Groups { private static Groups instance; private Groups() { - groups.add(new Group(GroupType.General, new Parameter())); + groups.add(new Group(GroupType.GENERAL, new Parameter())); groups.add(new Group(GroupType.VIP, new Parameter())); groups.add(new Group(GroupType.VVIP, new Parameter())); } diff --git a/src/main/java/me/smartstore/menu/GroupMenu.java b/src/main/java/me/smartstore/menu/GroupMenu.java index 96aae82e..e6269d17 100644 --- a/src/main/java/me/smartstore/menu/GroupMenu.java +++ b/src/main/java/me/smartstore/menu/GroupMenu.java @@ -1,7 +1,6 @@ package me.smartstore.menu; import me.smartstore.collections.MyArrayList; -import me.smartstore.customer.Customer; import me.smartstore.group.Group; import me.smartstore.group.GroupType; import me.smartstore.group.Parameter; @@ -51,7 +50,7 @@ public void addData() { private void printGroupSelectionMessage() { System.out.println("다음 등급 중 하나를 선택해주세요."); - System.out.println("1. General"); + System.out.println("1. GENERAL"); System.out.println("2. VIP"); System.out.println("3. VVIP"); System.out.println("=============================="); @@ -60,7 +59,7 @@ private void printGroupSelectionMessage() { private GroupType groupNumberToGroupType(int groupNumber) { if (groupNumber == 1) { - return GroupType.General; + return GroupType.GENERAL; } if (groupNumber == 2) { return GroupType.VIP; From 8cb91b06ed29a711bc1821f5c56da65dda18272b Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Mon, 15 May 2023 23:56:32 +0900 Subject: [PATCH 72/73] =?UTF-8?q?fix:=20=EB=93=B1=EA=B8=89=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20=EC=98=A4=EB=A5=98=EB=A5=BC=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/smartstore/customer/Customer.java | 18 +++++++++++++----- .../java/me/smartstore/customer/Customers.java | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/smartstore/customer/Customer.java b/src/main/java/me/smartstore/customer/Customer.java index ebd8d656..4e706718 100644 --- a/src/main/java/me/smartstore/customer/Customer.java +++ b/src/main/java/me/smartstore/customer/Customer.java @@ -28,14 +28,22 @@ private GroupType judgeCustomerGroup(int hours, int totalAmount) { //정렬된 groups요소를 돌며 그 요소의 기준 미만이라면 그 grouptype으로 설정 Groups groups = Groups.getInstance(); MyArrayList groupList = groups.getGroups(); - for (int i = 0; i < groupList.size(); i++) { - int minimumHours = groupList.get(i).getParameter().getMinimumHours(); - int minimumTotalAmount = groupList.get(i).getParameter().getMinimumTotalAmount(); - if (hours < minimumHours || totalAmount < minimumTotalAmount) { + for (int i = 0; i < groupList.size() - 1; i++) { + int currentMinimumHours = groupList.get(i).getParameter().getMinimumHours(); + int currentMinimumTotalAmount = groupList.get(i).getParameter().getMinimumTotalAmount(); + int nextMinimumHours = groupList.get(i + 1).getParameter().getMinimumHours(); + int nextMinimumTotalAmount = groupList.get(i + 1).getParameter().getMinimumTotalAmount(); + + //어떤 기준도 충족 못시킬 때 + if (hours <= currentMinimumHours || totalAmount <= currentMinimumTotalAmount) { + return GroupType.getGroupType(i); + } + //현재 기준 충족 + 다음 기준 미충족 시 현재 기준에 해당하는 등급 부여 + if (hours <= nextMinimumHours && totalAmount <= nextMinimumTotalAmount) { return groupList.get(i).getCustomerGroup(); } } - return GroupType.VVIP; + return GroupType.getGroupType(groupList.size() - 1); } public String getName() { diff --git a/src/main/java/me/smartstore/customer/Customers.java b/src/main/java/me/smartstore/customer/Customers.java index cfdd8ea6..37b0100c 100644 --- a/src/main/java/me/smartstore/customer/Customers.java +++ b/src/main/java/me/smartstore/customer/Customers.java @@ -31,15 +31,22 @@ public void refreshCustomersGroup() { int hours = currentCustomer.getHours(); int totalAmount = currentCustomer.getTotalAmount(); - for (int j = 0; j < groupList.size(); j++) { - int minimumHours = groupList.get(i).getParameter().getMinimumHours(); - int minimumTotalAmount = groupList.get(i).getParameter().getMinimumTotalAmount(); - if (hours < minimumHours || totalAmount < minimumTotalAmount) { + for (int j = 0; j < groupList.size() - 1; j++) { + int currentMinimumHours = groupList.get(i).getParameter().getMinimumHours(); + int currentMinimumTotalAmount = groupList.get(i).getParameter().getMinimumTotalAmount(); + int nextMinimumHours = groupList.get(i + 1).getParameter().getMinimumHours(); + int nextMinimumTotalAmount = groupList.get(i + 1).getParameter().getMinimumTotalAmount(); + //어떤 기준도 충족 못시킬 때 + if (hours <= currentMinimumHours || totalAmount <= currentMinimumTotalAmount) { + currentCustomer.setGroup(GroupType.getGroupType(0)); + return; + } + if (hours <= nextMinimumHours && totalAmount <= nextMinimumTotalAmount) { currentCustomer.setGroup(GroupType.getGroupType(i)); return; } } - currentCustomer.setGroup(GroupType.VVIP); + currentCustomer.setGroup(GroupType.getGroupType(groupList.size() - 1)); } } From 1b2ef801ea11ee8ba4a059d69f7889a231ff467f Mon Sep 17 00:00:00 2001 From: brotherstone97 Date: Tue, 16 May 2023 00:43:01 +0900 Subject: [PATCH 73/73] =?UTF-8?q?fix(Customers):=20=EB=93=B1=EA=B8=89=20?= =?UTF-8?q?=EA=B8=B0=EC=A4=80=20=EB=B3=80=EA=B2=BD=20=EC=8B=9C=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=EC=9D=B4=20=EC=95=88=EB=90=98=EB=8D=98=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EB=A5=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 반복문의 인덱스를 j가 아닌 i를 참조하던 것을 수정 --- .../java/me/smartstore/customer/Customers.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/smartstore/customer/Customers.java b/src/main/java/me/smartstore/customer/Customers.java index 37b0100c..7e57babb 100644 --- a/src/main/java/me/smartstore/customer/Customers.java +++ b/src/main/java/me/smartstore/customer/Customers.java @@ -32,18 +32,18 @@ public void refreshCustomersGroup() { int totalAmount = currentCustomer.getTotalAmount(); for (int j = 0; j < groupList.size() - 1; j++) { - int currentMinimumHours = groupList.get(i).getParameter().getMinimumHours(); - int currentMinimumTotalAmount = groupList.get(i).getParameter().getMinimumTotalAmount(); - int nextMinimumHours = groupList.get(i + 1).getParameter().getMinimumHours(); - int nextMinimumTotalAmount = groupList.get(i + 1).getParameter().getMinimumTotalAmount(); + int currentMinimumHours = groupList.get(j).getParameter().getMinimumHours(); + int currentMinimumTotalAmount = groupList.get(j).getParameter().getMinimumTotalAmount(); + int nextMinimumHours = groupList.get(j + 1).getParameter().getMinimumHours(); + int nextMinimumTotalAmount = groupList.get(j + 1).getParameter().getMinimumTotalAmount(); //어떤 기준도 충족 못시킬 때 if (hours <= currentMinimumHours || totalAmount <= currentMinimumTotalAmount) { - currentCustomer.setGroup(GroupType.getGroupType(0)); - return; + currentCustomer.setGroup(GroupType.getGroupType(j)); + break; } if (hours <= nextMinimumHours && totalAmount <= nextMinimumTotalAmount) { - currentCustomer.setGroup(GroupType.getGroupType(i)); - return; + currentCustomer.setGroup(GroupType.getGroupType(j)); + break; } } currentCustomer.setGroup(GroupType.getGroupType(groupList.size() - 1));