Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-validation")

implementation("org.mongodb:mongodb-driver-core:5.3.1")
implementation("org.mongodb:mongodb-driver-sync:5.3.1")
Comment on lines +22 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

MongoDB 드라이버 버전 호환성 확인 필요

Spring Boot 3.3.4와 MongoDB 드라이버 5.3.1의 호환성을 확인해야 합니다.


🌐 Web query:

What is the recommended MongoDB driver version for Spring Boot 3.3.4?

💡 Result:

The recommended MongoDB driver version for Spring Boot 3.3.4 is mongodb-driver-sync 5.0.1[9]. This version is explicitly listed as a direct dependency in the spring-boot-starter-data-mongodb:3.3.4 artifact[9], ensuring compatibility with Spring Data MongoDB 4.x[4][9].

Key compatibility details:

  • Spring Boot 3.x aligns with Spring Data MongoDB 4.x, which requires MongoDB Java Driver ≥5.x[4][7].
  • The mongodb-driver-sync:5.0.x line supports MongoDB server versions from 5.0 to 7.x according to MongoDB's compatibility matrix[3].

Avoid mixing older driver versions (e.g., 3.x or 4.x) with Spring Boot 3.x, as this causes conflicts like NoSuchMethodError or classpath incompatibilities[1][8]. If upgrading from legacy systems, ensure all related dependencies (Spring Data MongoDB and MongoDB Java Driver) are updated simultaneously[8][10].

Citations:


MongoDB 드라이버 버전 불일치 문제: Spring Boot 3.3.4에는 mongodb-driver-sync 5.0.1 버전을 권장합니다

  • 현재 **build.gradle.kts (라인 22-23)**에서 MongoDB 드라이버가 5.3.1 버전으로 지정되어 있습니다.
  • Spring Boot 3.3.4의 spring-boot-starter-data-mongodb에서는 mongodb-driver-sync 5.0.1 버전을 명시하고 있으므로, 권장 버전과 일치시켜 호환성 문제 및 예기치 않은 오류를 방지하는 것이 좋습니다.
  • 아래와 같이 변경을 고려해 주세요:
-    implementation("org.mongodb:mongodb-driver-core:5.3.1")
-    implementation("org.mongodb:mongodb-driver-sync:5.3.1")
+    implementation("org.mongodb:mongodb-driver-core:5.0.1")
+    implementation("org.mongodb:mongodb-driver-sync:5.0.1")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
implementation("org.mongodb:mongodb-driver-core:5.3.1")
implementation("org.mongodb:mongodb-driver-sync:5.3.1")
implementation("org.mongodb:mongodb-driver-core:5.0.1")
implementation("org.mongodb:mongodb-driver-sync:5.0.1")


developmentOnly("org.springframework.boot:spring-boot-devtools")

testImplementation("org.springframework.boot:spring-boot-starter-test")
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/example/demo/Application.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
package com.example.demo;

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoDatabase;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@Bean
public MongoClient mongoClient() {
return MongoClients.create("mongodb://localhost:27017");
}
Comment on lines +16 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

MongoDB 연결 설정 개선 필요

MongoDB 연결 문자열이 하드코딩되어 있어 환경에 따른 유연한 설정이 어렵습니다.

다음과 같이 수정하는 것을 제안합니다:

+import org.springframework.beans.factory.annotation.Value;

 @Bean
 public MongoClient mongoClient() {
-    return MongoClients.create("mongodb://localhost:27017");
+    @Value("${spring.data.mongodb.uri:mongodb://localhost:27017}")
+    private String mongoUri;
+    return MongoClients.create(mongoUri);
 }

Committable suggestion skipped: line range outside the PR's diff.


@Bean
public MongoDatabase mongoDatabase(MongoClient mongoClient) {
return mongoClient.getDatabase("demo");
}
Comment on lines +21 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

데이터베이스 이름을 설정 파일로 분리 필요

데이터베이스 이름도 환경에 따라 설정할 수 있도록 외부화가 필요합니다.

다음과 같이 수정하는 것을 제안합니다:

 @Bean
 public MongoDatabase mongoDatabase(MongoClient mongoClient) {
-    return mongoClient.getDatabase("demo");
+    @Value("${spring.data.mongodb.database:demo}")
+    private String databaseName;
+    return mongoClient.getDatabase(databaseName);
 }

Committable suggestion skipped: line range outside the PR's diff.

}
61 changes: 61 additions & 0 deletions src/main/java/com/example/demo/application/CartService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.example.demo.application;

import com.example.demo.infrastructure.LineItemDAO;
import com.example.demo.infrastructure.ProductDAO;
import com.example.demo.model.Cart;
import com.example.demo.model.LineItem;
import com.example.demo.model.Product;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartService {
private final LineItemDAO lineItemDAO;
private final ProductDAO productDAO;

public CartService(LineItemDAO lineItemDAO, ProductDAO productDAO) {
this.lineItemDAO = lineItemDAO;
this.productDAO = productDAO;
}

public Cart getCart() {
List<LineItem> lineItems = lineItemDAO.findAll();

lineItems.forEach(lineItem -> {
String productId = lineItem.getProductId();
Product product = productDAO.find(productId);

int unitPrice = product.getPrice();
int quantity = lineItem.getQuantity();

lineItem.setProductName(product.getName());
lineItem.setUnitPrice(product.getPrice());
lineItem.setTotalPrice(unitPrice * quantity);
});

int totalPrice = lineItems.stream()
.mapToInt(LineItem::getTotalPrice)
.sum();

return new Cart(lineItems, totalPrice);
}

public void addProduct(String productId, int quantity) {

List<LineItem> lineItems = lineItemDAO.findAll();

LineItem lineItem = lineItems.stream()
.filter(i -> i.getProductId().equals(productId))
.findFirst()
.orElse(null);

if (lineItem == null) {
lineItem = new LineItem(productId, quantity);
lineItemDAO.add(lineItem);
return;
}
lineItem.setQuantity(lineItem.getQuantity() + quantity);
lineItemDAO.update(lineItem);
}
}
32 changes: 30 additions & 2 deletions src/main/java/com/example/demo/controllers/CartController.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
package com.example.demo.controllers;

import com.example.demo.application.CartService;
import com.example.demo.controllers.dtos.CartDto;
import com.example.demo.model.Cart;
import com.example.demo.model.LineItem;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cart")
public class CartController {

private final CartService cartService;

public CartController(CartService cartService) {
this.cartService = cartService;
}

@GetMapping
String detail() {
return "";
CartDto detail() {

Cart cart = cartService.getCart();
return new CartDto(
cart.getLineItems().stream()
.map(this::mapToDto)
.toList(),
cart.getTotalPrice());
}

private CartDto.LineItemDto mapToDto(LineItem lineItem) {
return new CartDto.LineItemDto(
lineItem.getId(),
lineItem.getProductId(),
lineItem.getProductName(),
lineItem.getUnitPrice(),
lineItem.getQuantity(),
lineItem.getTotalPrice());
}
}
20 changes: 18 additions & 2 deletions src/main/java/com/example/demo/controllers/LineItemController.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
package com.example.demo.controllers;

import com.example.demo.application.CartService;
import com.example.demo.controllers.dtos.AddProductToCartDto;
import jakarta.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cart/line-items")
public class LineItemController {

private final CartService cartService;

public LineItemController(CartService cartService) {
this.cartService = cartService;
}

@PostMapping
@ResponseStatus(HttpStatus.CREATED)
void create() {
//
void create(
@Valid @RequestBody AddProductToCartDto addProductToCartDto
) {
cartService.addProduct(
addProductToCartDto.productId(),
addProductToCartDto.quantity()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.demo.controllers.dtos;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Positive;

public record AddProductToCartDto(
@NotBlank
String productId,
@Positive
int quantity
) {
}
18 changes: 18 additions & 0 deletions src/main/java/com/example/demo/controllers/dtos/CartDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.demo.controllers.dtos;

import java.util.List;

public record CartDto(
List<LineItemDto> lineItems,
int totalPrice
) {
public record LineItemDto(
String id,
String productId,
String productName,
int unitPrice,
int quantity,
int totalPrice
) {
}
}
56 changes: 56 additions & 0 deletions src/main/java/com/example/demo/infrastructure/LineItemDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.demo.infrastructure;

import com.example.demo.model.LineItem;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class LineItemDAO {

private final MongoCollection<Document> collection;

public LineItemDAO(MongoDatabase mongoDatabase) {
this.collection = mongoDatabase.getCollection("line_items");
}

public List<LineItem> findAll() {
List<Document> documents = new ArrayList<>();
collection.find().into(documents);

return documents.stream().map(this::mapToModel).toList();
}
Comment on lines +24 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

페이지네이션 구현이 필요합니다

대량의 데이터를 처리할 때 성능 문제가 발생할 수 있으므로, 페이지네이션을 구현하는 것이 좋습니다.

-    public List<LineItem> findAll() {
+    public List<LineItem> findAll(int skip, int limit) {
         List<Document> documents = new ArrayList<>();
-        collection.find().into(documents);
+        collection.find()
+                 .skip(skip)
+                 .limit(limit)
+                 .into(documents);
 
         return documents.stream().map(this::mapToModel).toList();
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public List<LineItem> findAll() {
List<Document> documents = new ArrayList<>();
collection.find().into(documents);
return documents.stream().map(this::mapToModel).toList();
}
public List<LineItem> findAll(int skip, int limit) {
List<Document> documents = new ArrayList<>();
collection.find()
.skip(skip)
.limit(limit)
.into(documents);
return documents.stream().map(this::mapToModel).toList();
}


public void add(LineItem lineItem) {
Document document = new Document()
.append("product_id", lineItem.getProductId())
.append("quantity", lineItem.getQuantity());

collection.insertOne(document);
}
Comment on lines +31 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

LineItem의 모든 필드를 저장해야 합니다

현재 product_idquantity만 저장하고 있습니다. 나머지 필드들도 저장이 필요합니다.

     public void add(LineItem lineItem) {
         Document document = new Document()
                 .append("product_id", lineItem.getProductId())
-                .append("quantity", lineItem.getQuantity());
+                .append("quantity", lineItem.getQuantity())
+                .append("product_name", lineItem.getProductName())
+                .append("unit_price", lineItem.getUnitPrice());
 
         collection.insertOne(document);
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void add(LineItem lineItem) {
Document document = new Document()
.append("product_id", lineItem.getProductId())
.append("quantity", lineItem.getQuantity());
collection.insertOne(document);
}
public void add(LineItem lineItem) {
Document document = new Document()
.append("product_id", lineItem.getProductId())
.append("quantity", lineItem.getQuantity())
.append("product_name", lineItem.getProductName())
.append("unit_price", lineItem.getUnitPrice());
collection.insertOne(document);
}


public void update(LineItem lineItem) {
collection.updateOne(
Filters.eq("_id", new ObjectId(lineItem.getId())),
Updates.combine(
Updates.set("product_id", lineItem.getProductId()),
Updates.set("quantity", lineItem.getQuantity())
)
);
}
Comment on lines +39 to +47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

모든 필드에 대한 업데이트가 필요합니다

현재 product_idquantity만 업데이트하고 있습니다. 모든 필드를 업데이트해야 합니다.

     public void update(LineItem lineItem) {
         collection.updateOne(
                 Filters.eq("_id", new ObjectId(lineItem.getId())),
                 Updates.combine(
                         Updates.set("product_id", lineItem.getProductId()),
-                        Updates.set("quantity", lineItem.getQuantity())
+                        Updates.set("quantity", lineItem.getQuantity()),
+                        Updates.set("product_name", lineItem.getProductName()),
+                        Updates.set("unit_price", lineItem.getUnitPrice())
                 )
         );
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void update(LineItem lineItem) {
collection.updateOne(
Filters.eq("_id", new ObjectId(lineItem.getId())),
Updates.combine(
Updates.set("product_id", lineItem.getProductId()),
Updates.set("quantity", lineItem.getQuantity())
)
);
}
public void update(LineItem lineItem) {
collection.updateOne(
Filters.eq("_id", new ObjectId(lineItem.getId())),
Updates.combine(
Updates.set("product_id", lineItem.getProductId()),
Updates.set("quantity", lineItem.getQuantity()),
Updates.set("product_name", lineItem.getProductName()),
Updates.set("unit_price", lineItem.getUnitPrice())
)
);
}


private LineItem mapToModel(Document document) {
return new LineItem(
document.getObjectId("_id").toString(),
document.getString("product_id"),
document.getInteger("quantity")
);
}
Comment on lines +49 to +55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

모든 필드를 매핑해야 합니다

Document에서 LineItem으로 변환 시 모든 필드가 매핑되어야 합니다.

     private LineItem mapToModel(Document document) {
         return new LineItem(
                 document.getObjectId("_id").toString(),
                 document.getString("product_id"),
-                document.getInteger("quantity")
+                document.getString("product_name"),
+                document.getInteger("quantity"),
+                document.getDouble("unit_price")
         );
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private LineItem mapToModel(Document document) {
return new LineItem(
document.getObjectId("_id").toString(),
document.getString("product_id"),
document.getInteger("quantity")
);
}
private LineItem mapToModel(Document document) {
return new LineItem(
document.getObjectId("_id").toString(),
document.getString("product_id"),
document.getString("product_name"),
document.getInteger("quantity"),
document.getDouble("unit_price")
);
}

}
37 changes: 37 additions & 0 deletions src/main/java/com/example/demo/infrastructure/ProductDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.example.demo.infrastructure;

import com.example.demo.model.LineItem;
import com.example.demo.model.Product;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ProductDAO {

private final MongoDatabase mongoDatabase;

public ProductDAO(MongoDatabase mongoDatabase) {
this.mongoDatabase = mongoDatabase;
}

public Product find(String productId) {

MongoCollection<Document> collection = mongoDatabase.getCollection("products");

Document document = collection.find(
Filters.eq("_id", new ObjectId(productId))
).first();

return new Product(
document.getObjectId("_id").toString(),
document.getString("name"),
document.getInteger("price")
);
}
Comment on lines +23 to +36
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

에러 처리 및 유효성 검사 추가 필요

현재 구현에는 다음과 같은 개선이 필요합니다:

  1. 문서를 찾지 못했을 때의 처리가 없습니다
  2. productId의 유효성 검사가 없습니다
  3. ObjectId 변환 시 예외 처리가 없습니다

다음과 같이 수정하는 것을 제안합니다:

 public Product find(String productId) {
+    if (productId == null || productId.trim().isEmpty()) {
+        throw new IllegalArgumentException("productId는 null이거나 비어있을 수 없습니다.");
+    }
+
+    ObjectId objectId;
+    try {
+        objectId = new ObjectId(productId);
+    } catch (IllegalArgumentException e) {
+        throw new IllegalArgumentException("유효하지 않은 productId 형식입니다.", e);
+    }

     MongoCollection<Document> collection = mongoDatabase.getCollection("products");

     Document document = collection.find(
-            Filters.eq("_id", new ObjectId(productId))
+            Filters.eq("_id", objectId)
     ).first();

+    if (document == null) {
+        throw new ProductNotFoundException("ID가 " + productId + "인 상품을 찾을 수 없습니다.");
+    }

     return new Product(
             document.getObjectId("_id").toString(),
             document.getString("name"),
             document.getInteger("price")
     );
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public Product find(String productId) {
MongoCollection<Document> collection = mongoDatabase.getCollection("products");
Document document = collection.find(
Filters.eq("_id", new ObjectId(productId))
).first();
return new Product(
document.getObjectId("_id").toString(),
document.getString("name"),
document.getInteger("price")
);
}
public Product find(String productId) {
if (productId == null || productId.trim().isEmpty()) {
throw new IllegalArgumentException("productId는 null이거나 비어있을 수 없습니다.");
}
ObjectId objectId;
try {
objectId = new ObjectId(productId);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("유효하지 않은 productId 형식입니다.", e);
}
MongoCollection<Document> collection = mongoDatabase.getCollection("products");
Document document = collection.find(
Filters.eq("_id", objectId)
).first();
if (document == null) {
throw new ProductNotFoundException("ID가 " + productId + "인 상품을 찾을 수 없습니다.");
}
return new Product(
document.getObjectId("_id").toString(),
document.getString("name"),
document.getInteger("price")
);
}

}
23 changes: 23 additions & 0 deletions src/main/java/com/example/demo/model/Cart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.demo.model;

import java.util.Collections;
import java.util.List;

public class Cart {
private List<LineItem> lineItems;
private int totalPrice;

public Cart(List<LineItem> lineItems, int totalPrice) {
this.lineItems = lineItems;
this.totalPrice = totalPrice;
}

public List<LineItem> getLineItems() {
return Collections.unmodifiableList(lineItems);
}

public int getTotalPrice() {
return totalPrice;
}

}
63 changes: 63 additions & 0 deletions src/main/java/com/example/demo/model/LineItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.example.demo.model;

public class LineItem {

private String id;
private String productId;
private int quantity;

private String productName;
private int unitPrice;
private int totalPrice;

Comment on lines +3 to +12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

모델 클래스에 유효성 검증이 필요합니다

수량(quantity)과 가격(unitPrice, totalPrice)에 대한 유효성 검증이 없습니다. 음수 값이 들어올 수 있는 위험이 있습니다.

Jakarta Validation 어노테이션을 사용하여 유효성 검증을 추가하는 것을 추천드립니다:

 public class LineItem {
     private String id;
     private String productId;
+    @Min(value = 1, message = "수량은 1 이상이어야 합니다")
     private int quantity;
 
     private String productName;
+    @Min(value = 0, message = "단가는 0 이상이어야 합니다")
     private int unitPrice;
+    @Min(value = 0, message = "총액은 0 이상이어야 합니다")
     private int totalPrice;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public class LineItem {
private String id;
private String productId;
private int quantity;
private String productName;
private int unitPrice;
private int totalPrice;
public class LineItem {
private String id;
private String productId;
@Min(value = 1, message = "수량은 1 이상이어야 합니다")
private int quantity;
private String productName;
@Min(value = 0, message = "단가는 0 이상이어야 합니다")
private int unitPrice;
@Min(value = 0, message = "총액은 0 이상이어야 합니다")
private int totalPrice;
}

public LineItem(String id, String productId, int quantity) {
this.id = id;
this.productId = productId;
this.quantity = quantity;
}

public LineItem(String productId, int quantity) {
this.productId = productId;
this.quantity = quantity;
}

public String getId() {
return id;
}

public String getProductId() {
return productId;
}

public int getQuantity() {
return quantity;
}

public String getProductName() {
return productName;
}

public void setProductName(String productName) {
this.productName = productName;
}

public int getUnitPrice() {
return unitPrice;
}

public void setUnitPrice(int unitPrice) {
this.unitPrice = unitPrice;
}

public int getTotalPrice() {
return totalPrice;
}

public void setTotalPrice(int totalPrice) {
this.totalPrice = totalPrice;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
Loading