-
Notifications
You must be signed in to change notification settings - Fork 1
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
[1์ฐจ VER1.0...] Java ToyProject upload by SeoYongHyun #11
Open
zjdtm
wants to merge
30
commits into
FastCampusKDTBackend:main
Choose a base branch
from
zjdtm:SeoYongHyun
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
30 commits
Select commit
Hold shift + click to select a range
d062594
Feat: Collections ์ธํฐํ์ด์ค, DArray ์ถ๊ฐ
zjdtm 358e961
Feat: Customer, Customers ์ถ๊ฐ
zjdtm a9736c8
Feat: ์ฌ์ฉ์ ์ ์ Exception ํด๋์ค๋ค ์ถ๊ฐ
zjdtm caa8d74
Feat: GroupType, Group, Parameter ์ถ๊ฐ
zjdtm 9fdf64b
Feat: Groups ์ถ๊ฐ
zjdtm 7f95b33
Feat: Main, SmartStoreApp ์ถ๊ฐ
zjdtm d6d5544
Feat: Menu ์ธํฐํ์ด์ค ์ถ๊ฐ
zjdtm d0d116d
refactor: allGroups -> this ๋ก ๋ฆฌํํฐ๋ง
zjdtm 084fe20
refactor: refresh ํจ์ ๋ฆฌํํฐ๋ง
zjdtm fe33cab
style: ์ปค๋ค๋ ์ฝ๋ ์์ ์ด ์์
zjdtm 531c86f
feat: Message ์ธํฐํ์ด์ค ์ถ๊ฐ
zjdtm b88530f
feat: GroupMenu ์ถ๊ฐ
zjdtm 71a24d3
feat: CustomerMenu ์ถ๊ฐ
zjdtm 5f0175b
feat: SummaryMenu ์ถ๊ฐ
zjdtm a339717
feat: MainMenu ์ถ๊ฐ
zjdtm 899c6bd
fix: setParameter ํจ์ ์์
zjdtm efd3cb0
fix: addCustomer, updateCustomer, viewCustomer ํจ์ ์์
zjdtm b923714
fix: addCustomer, updateCustomer, viewCustomer ํจ์ ์์
zjdtm f01356b
refactor: Customer ์์ฑ์ ํจ์ ๋ฆฌํํฐ๋ง
zjdtm c0756ad
feat: OrderType ์ถ๊ฐ
zjdtm 4ff3512
refactor: ๊ณ ๊ฐ์ด ์์ ๊ฒฝ์ฐ ์์ธ์ฒ๋ฆฌ
zjdtm ea1306e
style: Group ์ด ์
๋ ฅ๋์์ ๋ ์ถ๋ ฅ๋ฌธ, Message ์ถ๋ ฅ๋ฌธ ์์
zjdtm 3565a27
fix: Customer ์ถ๊ฐ ํ ์ ์์ธ์ฒ๋ฆฌ
zjdtm d41f83d
refactor: null ์ฒ๋ฆฌ, Group ์์ฑ์๋ฅผ ์ด์ฉํ ๊ฐ์ฒด ์์ฑ
zjdtm 1dba2bf
fix: Enter ๋ฅผ ์
๋ ฅ ๋ฐ์ ์ ์์ธ ์ฒ๋ฆฌ
zjdtm f5b2a33
style: ํ์ ์๋ import ์ญ์ ๋ฐ
zjdtm b3c2299
refactor: Groups ํด๋์ค์ findAllGroup ๋ฉ์๋ ์ถ๊ฐ
zjdtm 16668d6
refactor: addCustomer(), updateCustomer() ์ค๋ณต๋ ์ฝ๋ ๋ฆฌํํฐ๋ง
zjdtm b33d4b0
refactor: allGroups, allCustomers size ํธ์ถ ๋ฆฌํํฐ๋ง
zjdtm 936a72f
refactor: Customers ํด๋์ค์ groupCount(), findCustomerByGroup ๋ฉ์๋ ์ถ๊ฐ
zjdtm 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 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,8 @@ | ||
package me.smartstore; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
SmartStoreApp.getInstance().test().run(); // function chaining | ||
// SmartStoreApp.getInstance().run(); | ||
} | ||
} |
This file contains 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,66 @@ | ||
package me.smartstore; | ||
|
||
import me.smartstore.customer.Customer; | ||
import me.smartstore.customer.Customers; | ||
import me.smartstore.group.Group; | ||
import me.smartstore.group.GroupType; | ||
import me.smartstore.group.Groups; | ||
import me.smartstore.group.Parameter; | ||
import me.smartstore.menu.MainMenu; | ||
|
||
public class SmartStoreApp { | ||
private final Groups allGroups = Groups.getInstance(); | ||
private final Customers allCustomers = Customers.getInstance(); | ||
|
||
private final MainMenu mainMenu = MainMenu.getInstance(); | ||
|
||
private 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" + | ||
"โโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n" + | ||
"โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโโโโ \n" + | ||
"โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโโโโ \n" + | ||
"โโโโโโโโโโโ โโโ โโโโโโ โโโโโโ โโโ โโโ โโโโโโโโ โโโ โโโโโโโโโโโโ โโโโโโโโโโโ\n" + | ||
"โโโโโโโโโโโ โโโโโโ โโโโโโ โโโ โโโ โโโโโโโโ โโโ โโโโโโโ โโโ โโโโโโโโโโโ\n"); | ||
} | ||
|
||
public SmartStoreApp test() { | ||
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, | ||
null)); | ||
} | ||
|
||
allCustomers.refresh(allGroups); | ||
|
||
System.out.println("allCustomers = " + allCustomers); | ||
System.out.println("allGroups = " + allGroups); | ||
|
||
return this; // smartStoreApp | ||
} | ||
|
||
public void run() { | ||
details(); | ||
mainMenu.manage(); | ||
|
||
} | ||
} |
This file contains 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,16 @@ | ||
package me.smartstore.arrays; | ||
|
||
public interface Collections<T> { | ||
// ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ง๊ณ ์๋ ๊ฐ์ฒด๊ฐ ์๋ | ||
// ๊ตฌํ ํด์ผํ๋ ๋ฉ์๋์ ์ ๋ณด๋ง ๊ฐ์ง๊ณ ์์ (์ธํฐํ์ด์ค) | ||
|
||
int size(); | ||
T get(int index); | ||
void set(int index, T object); | ||
int indexOf(T object); | ||
void add(T object); | ||
void add(int index, T object); | ||
T pop(); | ||
T pop(int index); | ||
T pop(T object); | ||
} |
This file contains 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,145 @@ | ||
package me.smartstore.arrays; | ||
|
||
import me.smartstore.exception.ElementNotFoundException; | ||
import me.smartstore.exception.EmptyArrayException; | ||
import me.smartstore.exception.NullArgumentException; | ||
|
||
public class DArray<T> implements Collections<T> { // Dynamic Array | ||
|
||
protected static final int DEFAULT = 10; | ||
|
||
protected T[] arrays; | ||
protected int size; | ||
protected int capacity; | ||
|
||
public DArray() throws ClassCastException { | ||
arrays = (T[]) new Object[DEFAULT]; | ||
capacity = DEFAULT; | ||
} | ||
|
||
public DArray(int initial) throws ClassCastException { | ||
arrays = (T[]) new Object[initial]; | ||
capacity = initial; | ||
} | ||
|
||
public DArray(T[] arrays) { | ||
this.arrays = arrays; | ||
capacity = arrays.length; | ||
size = arrays.length; | ||
} | ||
|
||
///////////////////////////////////////// | ||
// add, set, get, pop, indexOf, size, capacity (for dynamic-sized array) | ||
|
||
@Override | ||
public int size() { | ||
return size; | ||
} | ||
|
||
// ๋ฐฐ์ด์ ์ผ๋ง๋ capacity ๋จ์์๋์ง ์ธ๋ถ์ ์๋ ค์ค ํ์๊ฐ ์๊ธฐ ๋๋ฌธ์ <protected>์ผ๋ก ์ ์ | ||
protected int capacity() { | ||
return capacity; | ||
} | ||
|
||
@Override | ||
public T get(int index) throws IndexOutOfBoundsException { | ||
if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); | ||
return arrays[index]; | ||
} | ||
|
||
/** | ||
* @param: ... | ||
* @return: ... | ||
* @throws: IndexOutOfBoundsException | ||
* @throws: NullArgumentException | ||
* */ | ||
@Override | ||
public void set(int index, T object) throws IndexOutOfBoundsException, NullArgumentException { | ||
if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); | ||
if (object == null) throw new NullArgumentException(); | ||
|
||
arrays[index] = object; | ||
} | ||
|
||
@Override | ||
public int indexOf(T object) throws NullArgumentException, ElementNotFoundException { | ||
if (object == null) throw new NullArgumentException(); // not found (instead of throwing exception) | ||
|
||
for (int i = 0; i < size; i++) { | ||
if (arrays[i] == null) continue; | ||
if (arrays[i].equals(object)) return i; | ||
} | ||
throw new ElementNotFoundException(); // not found | ||
} | ||
|
||
// ๋ฐฐ์ด์ cap์ด ๋ถ์กฑํ ๊ฒฝ์ฐ | ||
@Override | ||
public void add(T object) throws NullArgumentException { | ||
if (object == null) throw new NullArgumentException(); // if argument is null, do not add null value in array | ||
|
||
if (size < capacity) { | ||
arrays[size] = object; | ||
size++; | ||
} else { | ||
grow(); | ||
add(object); | ||
} | ||
} | ||
|
||
@Override | ||
public void add(int index, T object) throws IndexOutOfBoundsException, NullArgumentException { | ||
if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); | ||
if (object == null) throw new NullArgumentException(); | ||
|
||
if (size < capacity) { | ||
for (int i = size-1; i >= index ; i--) { | ||
arrays[i+1] = arrays[i]; | ||
} | ||
arrays[index] = object; | ||
size++; | ||
} else { | ||
grow(); | ||
add(index, object); | ||
} | ||
} | ||
|
||
@Override | ||
public T pop() { | ||
return pop(size-1); | ||
} | ||
|
||
@Override | ||
public T pop(int index) throws IndexOutOfBoundsException { | ||
if (size == 0) throw new EmptyArrayException(); | ||
if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); | ||
|
||
T popElement = arrays[index]; | ||
arrays[index] = null; // ์ญ์ ๋จ์ ๋ช ์์ ์ผ๋ก ํํ | ||
|
||
for (int i = index+1; i < size; i++) { | ||
arrays[i-1] = arrays[i]; | ||
} | ||
arrays[size-1] = null; | ||
size--; | ||
return popElement; | ||
} | ||
|
||
@Override | ||
public T pop(T object) { | ||
return pop(indexOf(object)); | ||
} | ||
|
||
protected void grow() { | ||
capacity *= 2; | ||
arrays = java.util.Arrays.copyOf(arrays, capacity); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String toStr = ""; | ||
for (int i = 0; i < size; i++) { | ||
toStr += (arrays[i] + "\n"); | ||
} | ||
return toStr; | ||
} | ||
} |
This file contains 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,121 @@ | ||
package me.smartstore.customer; | ||
|
||
import me.smartstore.exception.InputEmptyException; | ||
import me.smartstore.group.Group; | ||
import me.smartstore.group.GroupType; | ||
import me.smartstore.group.Parameter; | ||
|
||
public class Customer { | ||
private String cusName; | ||
private String cusId; | ||
private Integer cusTotalTime; | ||
private Integer cusTotalPay; | ||
private Group group; | ||
|
||
public Customer() { | ||
this.group = new Group(new Parameter(0, 0), GroupType.NONE); | ||
} | ||
|
||
public Customer(String cusId) { | ||
this.cusId = cusId; | ||
} | ||
|
||
public Customer(String cusName, String cusId) { | ||
this.cusName = cusName; | ||
this.cusId = cusId; | ||
} | ||
|
||
public Customer(String cusName, String cusId, Integer cusTotalTime, Integer cusTotalPay, Group group) { | ||
this.cusName = cusName; | ||
this.cusId = cusId; | ||
this.cusTotalTime = cusTotalTime; | ||
this.cusTotalPay = cusTotalPay; | ||
this.group = group; | ||
} | ||
|
||
public String getCusName() { | ||
return cusName; | ||
} | ||
|
||
public void setCusName(String cusName) { | ||
if(cusName.equals("")){ | ||
throw new InputEmptyException(); | ||
}else { | ||
this.cusName = cusName; | ||
} | ||
} | ||
|
||
public String getCusId() { | ||
return cusId; | ||
} | ||
|
||
public void setCusId(String cusId) { | ||
if(cusId.equals("")){ | ||
throw new InputEmptyException(); | ||
}else { | ||
this.cusId = cusId; | ||
} | ||
} | ||
|
||
public Integer getCusTotalTime() { | ||
return cusTotalTime; | ||
} | ||
|
||
public void setCusTotalTime(Integer cusTotalTime) { | ||
this.cusTotalTime = cusTotalTime; | ||
} | ||
|
||
public Integer getCusTotalPay() { | ||
return cusTotalPay; | ||
} | ||
|
||
public void setCusTotalPay(Integer cusTotalPay) { | ||
this.cusTotalPay = cusTotalPay; | ||
} | ||
|
||
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; | ||
|
||
if (getCusName() != null ? !getCusName().equals(customer.getCusName()) : customer.getCusName() != null) | ||
return false; | ||
if (getCusId() != null ? !getCusId().equals(customer.getCusId()) : customer.getCusId() != null) return false; | ||
if (getCusTotalTime() != null ? !getCusTotalTime().equals(customer.getCusTotalTime()) : customer.getCusTotalTime() != null) | ||
return false; | ||
if (getCusTotalPay() != null ? !getCusTotalPay().equals(customer.getCusTotalPay()) : customer.getCusTotalPay() != null) | ||
return false; | ||
return getGroup() != null ? getGroup().equals(customer.getGroup()) : customer.getGroup() == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = getCusName() != null ? getCusName().hashCode() : 0; | ||
result = 31 * result + (getCusId() != null ? getCusId().hashCode() : 0); | ||
result = 31 * result + (getCusTotalTime() != null ? getCusTotalTime().hashCode() : 0); | ||
result = 31 * result + (getCusTotalPay() != null ? getCusTotalPay().hashCode() : 0); | ||
result = 31 * result + (getGroup() != null ? getGroup().hashCode() : 0); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Customer{" + | ||
"cusName='" + cusName + '\'' + | ||
", cusId='" + cusId + '\'' + | ||
", cusTotalTime=" + cusTotalTime + | ||
", cusTotalPay=" + cusTotalPay + | ||
", group=" + group.getGroupType() + | ||
'}'; | ||
} | ||
} |
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.
์ฌ๊ธฐ์ Main ์ test๋ ๋น ์ ธ๋ ๊ด์ฐฎ์๊ฑฐ๊ฐ์ต๋๋ค :D