Implement the method that converts a Product to a ProductDTO object. The method should accept a Product instance and return an instance of ProductDTO created from the given Product.
Data Transfer Object in Spring
Converting a Java class to a DTO implementation
Report a typo
Sample Input 1:
No input.Sample Output 1:
Good job!Write a program in Java 17
class Product {
private long id;
private String model;
private int price;
private LocalDate dateOfArrival;
private String vendor;
public Product(long id, String model, int price, LocalDate dateOfArrival, String vendor) {
this.id = id;
this.model = model;
this.price = price;
this.dateOfArrival = dateOfArrival;
this.vendor = vendor;
}
public Product() { }
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getPrice() {
return price;
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.