Calling a method in java and returning beer cost

后端 未结 3 1672
轻奢々
轻奢々 2021-01-29 13:02

What I am supposed to do:

Add some necessary statements to the printOrderCost() method in the main class so that this method computes and p

3条回答
  •  囚心锁ツ
    2021-01-29 13:13

    Your code looks fine to me. To call getCost() in toString() method, simply just call it with getCost().

    So your toString() method should be something like this:

    public toString(){
        String s;
        s = brand + " ";
        s += quantity + " " ;
        s += itemCost + " ";
        s += getCost();
    
        return s;
    }
    

    Hope this is what you're looking for :)

提交回复
热议问题