Sort by

recency

|

126 Discussions

|

  • + 0 comments

    You can also follow this approach using String.format @Override void getNumberOfTeamMembers(){ int n=11; String result = String.format( "Each team has %d players in %s",n,getName() ); System.out.println(result); }

  • + 0 comments

    This suck .. getNumberOfTeamMembers() should at least be able to get n from a setNumberOfTeamMembers(int nbrplayer).

  • + 0 comments

    import java.util.Scanner; class Sports { String getName() { return "Generic Sports"; } void getNumberOfTeamMembers() { System.out.println("Each team has n players in "+getName()); } } class Soccer extends Sports { String getName(){ return "Soccer Class"; } void getNumberOfTeamMembers() { System.out.println("Each team has 11 players in "+getName()); } } class Solution { public static void main(String[] args) { Sports s = new Sports(); Soccer s1 = new Soccer(); System.out.println(s.getName()); s.getNumberOfTeamMembers(); System.out.println(s1.getName()); s1.getNumberOfTeamMembers();

    }
    

    }

  • + 0 comments

    This code work you have to write only bold text import java.util.*; class Sports{

    String getName(){
        return "Generic Sports";
    }
    
    void getNumberOfTeamMembers(){
        System.out.println( "Each team has n players in " + getName() );
    }
    

    }

    class Soccer extends Sports{ @Override String getName(){ return "Soccer Class"; }

    // Write your overridden getNumberOfTeamMembers method here
    

    ** @Override void getNumberOfTeamMembers() { System.out.println("Each team has 11 players in " + getName());** }

    }

    public class Solution{

    public static void main(String []args){
        Sports c1 = new Sports();
        Soccer c2 = new Soccer();
        System.out.println(c1.getName());
        c1.getNumberOfTeamMembers();
        System.out.println(c2.getName());
        c2.getNumberOfTeamMembers();
    }
    

    }

  • + 0 comments

    why this code is not working? import java.util.*; class Sports{

    String getName(){
        return "Generic Sports";
    }
    
    void getNumberOfTeamMembers(){
        System.out.println( "Each team has n players in " + getName() );
    }
    

    }

    class Soccer extends Sports{ @Override String getName(){ return "Soccer Class"; } class Sports{ String getName(){ return "Generic Sports"; } void getNumberOfTeamMembers(){ System.out.println("Each has n players in"+getName()); } } class Succer extends Sports{ String getName(){ return "Succer Class"; } void getNumberOfTeamMembers(){ System.out.println("Each has 11 players in"+getName()); } } // Write your overridden getNumberOfTeamMembers method here

    }

    public class Solution{

    public static void main(String []args){
        Sports c1 = new Sports();
        Soccer c2 = new Soccer();
        System.out.println(c1.getName());
        c1.getNumberOfTeamMembers();
        System.out.println(c2.getName());
        c2.getNumberOfTeamMembers();
    }
    

    }