-
Notifications
You must be signed in to change notification settings - Fork 1
[1차 VER1.0] Java ToyProject upload by TaeIlKIM #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
james-taeil
wants to merge
18
commits into
FastCampusKDTBackend:main
Choose a base branch
from
james-taeil:taeilKim
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e957a12
add: gitignore
james-taeil 77a314e
feat: class customer setting
james-taeil b297e33
add: field group
james-taeil 80562b8
feat: setParameter, viewParameter, updateParameter
james-taeil a7bdf78
fix: access controller
james-taeil d2a9dd1
remove: println:66, println:34
james-taeil 07a2747
feat: class exception init
james-taeil 7c52baa
fix: refresh function
james-taeil 9f2e2a8
feat: comparator method, customer init, sortSummary
james-taeil 2475f9c
feat: group init
james-taeil 5fe0f35
feat: find method
james-taeil e2fe88e
feat: menu init
james-taeil 9abcef9
feat: domain mainmenu init
james-taeil edfa5d3
feat: customermenu method, add, info, set, view, update, delete
james-taeil c7c4d6a
feat: summary menu method, get, display, sort
james-taeil a484717
feat: domain test handling, main class
james-taeil bd0ec4a
feat: util enum print board, error message init
james-taeil 3b00a96
feat: specification markdown
james-taeil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
### Java template | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
|
||
.idea | ||
out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# 프로젝트 요구사항 | ||
|
||
## Customer | ||
|
||
### 명세서 | ||
|
||
|
||
고객 속성 | ||
- 고객 이름 | ||
- 고객 아이디 | ||
- 고객 스마트스토어를 이용시간 | ||
- 고객 스마트스토어에서 구매한 총 결제금액서 | ||
- Group 속성 추가 | ||
|
||
### 요구사항 | ||
|
||
- Customers - Refresh() 메서드 구현 | ||
- Customers - Summary sort 메서드 구현 | ||
- Customers - 정렬 로직 구현 | ||
|
||
### 해결책 및 코드 로직 | ||
|
||
1. 속성 만들기 | ||
2. Getter, Setter 구현 | ||
|
||
## Group | ||
|
||
### 요구 사항 | ||
|
||
- Groups - find() 구현 | ||
|
||
### 명세서 | ||
|
||
- 분류 기준 : 시간 - 금액 | ||
- General | ||
- VIP | ||
- VVIP | ||
- NONE | ||
|
||
### 해결책 및 코드 로직 | ||
|
||
|
||
1. Parameter (minTime, minPay) | ||
|
||
## Menu | ||
|
||
### 요구 사항 | ||
|
||
분류기준 | ||
- 고객의 분류기준을 입력할 수 있다. | ||
- 고객의 분류기준을 설정할 수 있다. | ||
- 고객의 분류기준을 수정할 수 있다. | ||
|
||
|
||
고객정보 | ||
- 고객의 정보를 입력할 수 있다. | ||
- 고객의 정보를 추가할 수 있다. | ||
- 고객의 정보를 삭제할 수 있다. | ||
|
||
|
||
고객 분류기능 | ||
- 분류기준에 의해 고객을 분류할 수 있다. | ||
- 분류기준에 의해 분류된 고객의 정보를 출력할 수 있다. | ||
- 분류기준에 의해 분류된 고객의 정보를 이름순으로 정렬할 수 있다. | ||
- 분류기준에 의해 분류된 고객의 정보를 총 이용시간 순으로 정렬할 수 있다. | ||
- 분류기준에 의해 분류된 고객의 정보를 총 결제금액 순으로 정렬할 수 있다. | ||
|
||
### 해결책 및 코드 로직 | ||
|
||
1. GroupMenu | ||
- Set Parameter | ||
- View Parameter | ||
- Update Parameter | ||
|
||
2. CustomerMenu | ||
- Add Customer Data | ||
- View Customer Data | ||
- Update Customer Data | ||
- Delete Customer Data | ||
|
||
3. SummaryMenu | ||
- Summary view | ||
- By Name Sort | ||
- By Time Sort | ||
- By Pay Sort | ||
|
||
|
||
## TODO - Refactoring | ||
|
||
- [ ] Summary sort 반복적인 코드 일관성 있게 리펙토링 필요 | ||
- [ ] TEST코드 구현 필요 | ||
- [ ] 반복되는 코드 객체지향적으로 풀이 필요 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package me.smartstore; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
SmartStoreApp.getInstance().test().run(); // function chaining | ||
// SmartStoreApp.getInstance().run(); | ||
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package me.smartstore; | ||
|
||
import me.smartstore.customers.Customer; | ||
import me.smartstore.customers.Customers; | ||
import me.smartstore.groups.Group; | ||
import me.smartstore.groups.GroupType; | ||
import me.smartstore.groups.Groups; | ||
import me.smartstore.groups.Parameter; | ||
import me.smartstore.menu.MainMenu; | ||
import me.smartstore.menu.Menu; | ||
|
||
public class SmartStoreApp { | ||
private final Groups allGroups = Groups.getInstance(); | ||
private final Customers allCustomers = Customers.getInstance(); | ||
private final MainMenu mainMenu = MainMenu.getInstance(); | ||
|
||
// singleton | ||
public static SmartStoreApp smartStoreApp; | ||
|
||
public static SmartStoreApp getInstance() { | ||
if (smartStoreApp == null) { | ||
smartStoreApp = new SmartStoreApp(); | ||
} | ||
return smartStoreApp; | ||
} | ||
|
||
private SmartStoreApp() {} | ||
|
||
public void details() { | ||
System.out.println("\n\n==========================================="); | ||
System.out.println(" Title : SmartStore Customer Classification"); | ||
System.out.println(" Release Date : 23.04.27"); | ||
System.out.println(" Copyright 2023 Eunbin All rights reserved."); | ||
System.out.println("===========================================\n"); | ||
} | ||
|
||
// who type is SmartStoreApp | ||
// 체이닝이 되어야 하니까. test().run() | ||
public SmartStoreApp test() { | ||
allGroups.add(new Group(new Parameter(0, 0), GroupType.NONE)); | ||
// allGroups.add(new Group(new Parameter(10, 100000), GroupType.GENERAL)); | ||
allGroups.add(new Group(new Parameter(20, 200000), GroupType.VIP)); | ||
allGroups.add(new Group(new Parameter(30, 300000), GroupType.VVIP)); | ||
|
||
for (int i = 0; i < 26; i++) { | ||
allCustomers.add(new Customer( | ||
Character.toString((char)('a' + i)), | ||
(char)('a' + i) + "123", | ||
((int) (Math.random() * 5)+ 1) * 10, | ||
((int) (Math.random() * 5) + 1) * 100000)); | ||
} | ||
|
||
|
||
System.out.println("allCustomers = " + allCustomers); | ||
System.out.println("allGroups = " + allGroups); | ||
|
||
// @TODO | ||
// allCustomers.refresh(allGroups); | ||
|
||
return this; | ||
} | ||
|
||
public void run() { | ||
details(); | ||
mainMenu.manage(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package me.smartstore.customers; | ||
|
||
import me.smartstore.groups.Group; | ||
|
||
import java.util.Objects; | ||
|
||
public class Customer { | ||
private String cName; | ||
private String cId; | ||
private Integer totalTime; | ||
private Integer totalPay; | ||
private Group group; | ||
|
||
public Customer() { | ||
} | ||
|
||
public Customer(String cName, String cId) { | ||
this.cName = cName; | ||
this.cId = cId; | ||
} | ||
|
||
public Customer(String cName, String cId, Integer totalTime, Integer totalPay) { | ||
this.cName = cName; | ||
this.cId = cId; | ||
this.totalTime = totalTime; | ||
this.totalPay = totalPay; | ||
} | ||
|
||
public String getcName() { | ||
return cName; | ||
} | ||
|
||
public void setcName(String cName) { | ||
this.cName = cName; | ||
} | ||
|
||
public String getcId() { | ||
return cId; | ||
} | ||
|
||
public void setcId(String cId) { | ||
this.cId = cId; | ||
} | ||
|
||
public Integer getTotalTime() { | ||
return totalTime; | ||
} | ||
|
||
public void setTotalTime(Integer totalTime) { | ||
this.totalTime = totalTime; | ||
} | ||
|
||
public Integer getTotalPay() { | ||
return totalPay; | ||
} | ||
|
||
public void setTotalPay(Integer totalPay) { | ||
this.totalPay = totalPay; | ||
} | ||
|
||
public Group getGroup() { | ||
return group; | ||
} | ||
|
||
public void setGroup(Group 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 Objects.equals(cName, customer.cName) && Objects.equals(cId, customer.cId) && Objects.equals(totalTime, customer.totalTime) && Objects.equals(totalPay, customer.totalPay) && Objects.equals(group, customer.group); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(cName, cId, totalTime, totalPay, group); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Customer{" + | ||
"cName='" + cName + '\'' + | ||
", cId='" + cId + '\'' + | ||
", totalTime=" + totalTime + | ||
", totalPay=" + totalPay + | ||
", group=" + group + | ||
'}'; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package me.smartstore.customers; | ||
|
||
import me.smartstore.groups.Group; | ||
import me.smartstore.groups.Groups; | ||
import me.smartstore.util.arrays.Array; | ||
|
||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
|
||
public class Customers extends Array<Customer> { | ||
private static Customers allCustomers; | ||
private final Groups allGroups = Groups.getInstance(); | ||
|
||
public static Customers getInstance() { | ||
if (allCustomers == null) { | ||
allCustomers = new Customers(); | ||
} | ||
return allCustomers; | ||
} | ||
|
||
private Customers() {}; | ||
|
||
public void refresh() { | ||
for (int i = 0; i < allCustomers.size(); i++) { | ||
Customer customer = allCustomers.get(i); | ||
|
||
|
||
for (int j = 0; j < allGroups.size(); j++) { | ||
Group group = allGroups.get(j); | ||
|
||
if (group.getParmeter().getMinTime() == null || group.getParmeter().getMinPayment() == null || | ||
customer.getTotalPay() == null || customer.getTotalTime() == null) { | ||
continue; | ||
} | ||
|
||
if ((customer.getTotalTime() >= group.getParmeter().getMinTime()) && (customer.getTotalPay() >= group.getParmeter().getMinPayment())) { | ||
customer.setGroup(group); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
public Customer[] sortSummary(Comparator<Customer> comparator) { | ||
Customer[] customerArr = initCustomers(); | ||
Arrays.sort(customerArr, comparator); | ||
return customerArr; | ||
} | ||
|
||
public Customer[] initCustomers() { | ||
Customer[] customerArrs = new Customer[allCustomers.size()]; | ||
|
||
for (int i = 0; i < allCustomers.size(); i++) { | ||
customerArrs[i] = allCustomers.get(i); | ||
} | ||
return customerArrs; | ||
} | ||
|
||
public Comparator<Customer> sortName(int num) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 람다식으로 할 생각은 전혀 못했었는데 덕분에 하나 배워갑니다!👍 |
||
return (customer1, customer2) -> num * customer1.getcName().compareTo(customer2.getcName()); | ||
} | ||
|
||
public Comparator<Customer> sortTime(int num) { | ||
return (customer1, customer2) -> num * customer1.getTotalTime().compareTo(customer2.getTotalTime()); | ||
} | ||
|
||
public Comparator<Customer> sortPay(int num) { | ||
return (customer1, customer2) -> num * customer1.getTotalPay().compareTo(customer2.getTotalPay()); | ||
} | ||
|
||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refresh 메서드를 오버로딩해서 한 고객에 대해서만 업데이트하는 메서드가 있으면 좋을 것 같습니다!
고객 한 명을 추가했는데 모든 고객을 refresh한다면 비효율적이니까요 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그런 생각 안해봤는데, 참고해보겠습니다~