+ 1
Write a code snippet that if you buy shirts to say i bought shirts. If you instead bought shoes, let it say i bought one pair
2 Answers
+ 7
Does it have to be java?
https://code.sololearn.com/c00N814GW1x7/#cpp
+ 5
void buyShirt(){
System.out.println("I bought shirts!");
}
void buyShoes(){
System.ot.println("I bought one pair!");
}
void buy(String item){
if(item.equals("shoes")){
buyShoes();
}else if(item.equals("shirt")){
buyShirt();
}else{
System.out.println("Buy something else");
}
}