我的第二个if / else语句中有一个小故障,我想,你能帮我找到吗? 一次单词== 1单词的值应该改为“bottle”但是它正在打印“瓶子”。
public class milkSong
{
public static void main(String[] args) {
int milkNum = 10; //decreased the bottles of milk so that the output would fit
String word = "bottles";
while (milkNum > 0) {
if (milkNum == 1) {
word = "bottle";
}
System.out.println (milkNum + " " + word + " of milk on the wall.");
System.out.println (milkNum + " " + word + " of milk.");
System.out.println ("Take one down.");
System.out.println ("Pass it around.");
milkNum = milkNum - 1;
//There is a problem with this statement, once beerNum == 1, still printing "bottles"
if (milkNum > 0) {
System.out.println (milkNum + " " + word + " of milk on the wall.");
}
else {
System.out.println ("No more bottles of milk on the wall.");
}
}
}
}
答案 0 :(得分:6)
将 Mapper.CreateMap<OneObject, AnotherObject>()
.ForMember(
destination => destination.complexelement,
option => option.MapFrom(source=> source.value == enumValue.ToString()
? new object( {Id 123 })
: new object ({ Id 567 }))
的设置移至word