Class has two properties of the same name "xxx"

webservice 调用报错。

a实体里面有 b实体 ,b 实体中有c实体。

结果b实体中 一直报 重复的属性

参考:

https://developer.ibm.com/answers/questions/181324/class-has-two-properties-of-the-same-name-error-wh.html


在b实体类上加了

@XmlRootElement(name = "xxx")
@XmlAccessorType(XmlAccessType.FIELD)
就可以了。

```python class PropertyManagementCompany: def __init__(self, name, liquidity, properties=None): self.checkName(name) self.name = name self.liquidity = liquidity if properties is None: self.portfolio = [] else: self.portfolio = properties def buyProperty(self, property, purchasePrice): if self.liquidity >= purchasePrice: self.portfolio.append(property) self.liquidity -= purchasePrice def sellProperty(self, property): if property in self.portfolio: self.portfolio.remove(property) self.liquidity += property.currentValuation def getName(self): return self.name def getLiquidity(self): return self.liquidity def getPortfolio(self): return self.portfolio def checkName(self, name): if name == '': raise ValueError('Company name cannot be empty.') ``` For example, we can create a new PropertyManagementCompany as follows: ```python properties = [Property('123 Main St.', 100000), Property('456 Oak Ave.', 200000)] company = PropertyManagementCompany('ABC Company', 500000, properties) ``` This creates a company named "ABC Company" with $500,000 liquidity and a portfolio containing two properties. We can then buy a new property and sell an existing property using the `buyProperty` and `sellProperty` methods: ```python newProperty = Property('789 Elm St.', 150000) company.buyProperty(newProperty, 150000) propertyToSell = properties[0] company.sellProperty(propertyToSell) ``` This would add the new property to the portfolio and remove the first property from the portfolio while adding its current valuation to the company's liquidity.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值