以下是一個使用Java BidRequest類的示例:
public class BidRequest {
private String id;
private String placementId;
private String publisherId;
private double bidAmount;
public BidRequest(String id, String placementId, String publisherId, double bidAmount) {
this.id = id;
this.placementId = placementId;
this.publisherId = publisherId;
this.bidAmount = bidAmount;
}
public String getId() {
return id;
}
public String getPlacementId() {
return placementId;
}
public String getPublisherId() {
return publisherId;
}
public double getBidAmount() {
return bidAmount;
}
public void setId(String id) {
this.id = id;
}
public void setPlacementId(String placementId) {
this.placementId = placementId;
}
public void setPublisherId(String publisherId) {
this.publisherId = publisherId;
}
public void setBidAmount(double bidAmount) {
this.bidAmount = bidAmount;
}
public static void main(String[] args) {
BidRequest bidRequest = new BidRequest("123456", "placement123", "publisher789", 10.00);
System.out.println("Bid Request ID: " + bidRequest.getId());
System.out.println("Placement ID: " + bidRequest.getPlacementId());
System.out.println("Publisher ID: " + bidRequest.getPublisherId());
System.out.println("Bid Amount: $" + bidRequest.getBidAmount());
bidRequest.setBidAmount(15.00);
System.out.println("Updated Bid Amount: $" + bidRequest.getBidAmount());
}
}
這個例子中,我們創建了一個BidRequest類,它有四個屬性:id、placementId、publisherId和bidAmount。構造函數用于初始化這些屬性。然后我們定義了getter和setter方法來訪問和修改這些屬性。在main方法中,我們創建了一個BidRequest對象,并打印出其屬性值。然后,我們修改了bidAmount屬性的值,并再次打印出來。