๋ฐ์ํ
package quiz;
public class OrderData {
private int orderNum;
private String orderProduct;
private int price;
private int qty;
private MemberData memberData;
public OrderData() {
}
public OrderData(int orderNum, String orderProduct, int price, int qty, MemberData memberdata) {
this.orderNum = orderNum;
this.orderProduct = orderProduct;
this.price = price;
this.qty = qty;
this.memberData = memberdata;
}
public OrderData(int orderNum, String orderProduct, int price, int qty, String ID, String name, String tel,
String gender) {
this.orderNum = orderNum;
this.orderProduct = orderProduct;
this.price = price;
this.qty = qty;
this.memberData = new MemberData(ID, name, tel, gender);
}
public int getOrderNum() {
return orderNum;
}
public void setOrderNum(int orderNum) {
this.orderNum = orderNum;
}
public String getOrderProduct() {
return orderProduct;
}
public void setOrderProduct(String orderProduct) {
this.orderProduct = orderProduct;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public MemberData getMemberData() {
return memberData;
}
public void setMemberData(MemberData memberData) {
this.memberData = memberData;
}
public void showInfo() {
System.out.println("์ฃผ๋ฌธ๋ฒํธ:" + orderNum + "\t์ํ์ด๋ฆ:" + orderProduct + "\t์ํ๊ฐ๊ฒฉ:" + price + "\t๊ฐฏ์:" + qty);
}
int[][] arr = { { 1, 2, 3 }, { 4, 5, 6, } };
}
InitData.java
package quiz;
import java.util.ArrayList;
public class InitData {
public ArrayList<OrderData> productQtyInit(ArrayList<OrderData> list) {
for (int i = 0; i < list.size(); i++) {
list.get(i).setQty(0);
}
return list;
}
public ArrayList<OrderData> productTelInit(ArrayList<OrderData> list) {
for (int i = 0; i < list.size(); i++) {
list.get(i).getMemberData().setTel("");
}
return list;
}
}
OrderTest.java
package quiz;
import java.util.ArrayList;
public class OrderTest {
public static void main(String[] args) {
ArrayList<OrderData> list = new ArrayList<OrderData>();
OrderData orderData = new OrderData();
orderData.setOrderNum(200713001);
orderData.setOrderProduct("๋ฐํ์
์ธ ");
orderData.setPrice(25000);
orderData.setQty(3);
MemberData memberData = new MemberData("M2020001", "ํ๊ธธ๋", "010-1111-2221", "๋จ");
orderData.setMemberData(memberData);
list.add(orderData);
list.add(new OrderData(200713001, "๋ฐ๋ฐ์ง", 20000, 2, memberData));
list.add(new OrderData(200713002, "ํ๋งคํธ", 4000, 3, new MemberData("M2020002", "์ ์ฌ์๋น", "010-2222-2223", "์ฌ")));
list.add(new OrderData(200713002, "๋ง์คํฌ", 500, 50, "M2020002", "์ ์ฌ์๋น", "010-2222-2223", "์ฌ"));
for (int i = 0; i < list.size(); i++) {
list.get(i).showInfo();
}
System.out.println();
InitData id = new InitData();
list = id.productQtyInit(list);
for (int i = 0; i < list.size(); i++) {
list.get(i).showInfo();
}
}
}
<๊ฒฐ๊ณผ๊ฐ>
๋ฐ์ํ
'Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java-๊ธฐ์ด] ์ค์ต (ํฉ๊ณ, ํ๊ท , ์์ฐจ ์ฐ์ถ ํ๋ก๊ทธ๋จ) (0) | 2021.02.24 |
---|---|
[Java-๊ธฐ์ด] ์ค์ต (๋ฉค๋ฒ ํธ์ถ) (0) | 2021.02.24 |
[Java-๊ธฐ์ด] ์ค์ต (๋ฉ์๋๋ก ๊ตฌ๊ตฌ๋จ ํธ์ถํ๊ธฐ) (0) | 2021.02.24 |
[Java-๊ธฐ์ด] ์ค์ต (๋ก๋ ์ถ์ฒจ ๋ฒํธ) (0) | 2021.02.24 |
[Java-๊ธฐ์ด] ์๊ณ ๋ฆฌ์ฆ ์ค์ต (๋ง๋ฐฉ์ง) (0) | 2021.02.24 |
๋๊ธ