Question

Questions 7 and 8 refer to the SoccerTeam class partially implemented in Appendix A. Assume that the comments are correct ifAPPENDIX A-SoccerTeam.java (Questions 7 and 8) Creates a SoccerTeam with specified official name and nick name. @param offici

Questions 7 and 8 refer to the SoccerTeam class partially implemented in Appendix A. Assume that the comments are correct if there is disagreement between the code in SoccerTeam or the test cases do not implement/interact with the methods correctly. Assume that any code missing from SoccerTeam.java does not affect your answer in any way QUESTION 7 What would be the result of the following JUnit test case and why? eTest (expected = TeamException.class) public void Testl() throws TeamException String emptyString SoccerTeam team = new SoccerTeam (emptyString, "Dark Knights"); assertEquals (team.getofficialName (), emptyString); ="": The test will pass because assertEquals returns true The test will report an error (a) (b) (c) The test will fail due to a bug in the test code. The test will fail due to a bug in SoccerTeam.java None of the above (d) (e) QUESTION 8 What would be the result of the following JUnit test case and why? еTest public void Test2 () throws TeamException { SoccerTeam teaml = new SoccerTeam ("Gotham City", "Dark Knights"); new SoccerTeam ("Metropolis", "Men of Steel"); SoccerTeam team2 teaml.playMatch (3, 0); team2.playMatch (0, 3) assertEquals (teaml.compareTO (team2), -1); The test wil pass because assertEquals returns true The test will report an error The test will fail due to a bug in the test code The test will fail due to a bug in SoccerTeam.java (b) (c) (d) None of the above. (e) ЭэээО
APPENDIX A-SoccerTeam.java (Questions 7 and 8) Creates a SoccerTeam with specified official name and nick name. @param official The official name of the soccer team. @param nick The nick name of the soccer team. @throws TeamException If official or nick are empty strings. * public Soccer Team (String official, String nick) throws TeamException ( if (official.length ( -= 0) throw new TeamException () ; if (nick.length ) 0 throw new TeamException () this.official Nameofficial; this.nickName nick; this.goalsScoredSeason 0; this.goalsConcededSeason = 0; this.matchesWon 0; this.matchesLost 0 this.matchesDrawn 0; this.competition Points 0 *Returns the team's official name. return The team's official name. public String getofficialName () return officialName Plays a match for a team, A team wins if it has more goals for than against, loses if it has less goals for than against, and draws if the goals are equal. Teams are awarded 3 competition points for a win, 1 point for a draw and 0 points for a loss Other statistics are updated sensibly. @param goalsFor The number of goals scored by the team. @param goalsAgainst The number of goals conceded by the team. public void playMatch (int goalsFor, int goalsAgainst) goalsScoredSeason +goalsFor goalsConcededSeason + goalsAgainst; if (goalsFor goalsAgainst) matchesWon++; competitionPoints +-3; else if (goalsFor
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) The Test will pass because asserEqual returns True

Explanation:
Since we have mentioned that expected is the exception and since exception was expected and we got a chance to test if the variable is emoty which is true, hence the Test will pass


B) Test will report an error

team1 scored 3 goals hence their competetion points are 3
team2 scored 0 goals hence their competetion points are 0

So team1.compare(team2) will give us 1 and NOT -1

Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
Questions 7 and 8 refer to the SoccerTeam class partially implemented in Appendix A. Assume that the comments are corre...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • /** * Notes: * You must use RECURSION to solve the problems. Your code may not...

    /** * Notes: * You must use RECURSION to solve the problems. Your code may not contain any loops. * You may not change any of the fields, nor the constructor, nor the insertAtFront method. * You may not modify the method headers given to you in any way nor may you change the name of the class or the package. */ package hw8; import java.util.NoSuchElementException; public class MyList<Item> {    private class MyListNode {        public Item item;...

  • This is Crypto Manager blank public class CryptoManager { private static final char LOWER_BOUND = '...

    This is Crypto Manager blank public class CryptoManager { private static final char LOWER_BOUND = ' '; private static final char UPPER_BOUND = '_'; private static final int RANGE = UPPER_BOUND - LOWER_BOUND + 1; /** * This method determines if a string is within the allowable bounds of ASCII codes * according to the LOWER_BOUND and UPPER_BOUND characters * @param plainText a string to be encrypted, if it is within the allowable bounds * @return true if all characters...

  • Public class File {    public String base; //for example, "log" in "log.txt"  &nbs...

    public class File {    public String base; //for example, "log" in "log.txt"    public String extension; //for example, "txt" in "log.txt"    public int size; //in bytes    public int permissions; //explanation in toString public String getExtension() {        return extension;    } public void setExtension(String e) {           if(e == null || e.length() == 0)            extension = "txt";        else            extension = e;    } public class FileCollection {    private File[] files;    /**    * DO NOT MODIFY    * Loads collection from input file    * @param input: name...

  • This wont take you more than 15 mins. Comple the two method and besure to test...

    This wont take you more than 15 mins. Comple the two method and besure to test with Junit test that provided below. toArray() -- this method returns a newly allocated array containing the elements in the multiset. The array this method returns must only contain the elements in the multiset and not any nulls or other values that are stored in the backing store, but are not in the multiset. fromArray(E[] arr) -- this method updates the multiset so that...

  • Write a unit test to test the following class. Using Java : //Test only the debit...

    Write a unit test to test the following class. Using Java : //Test only the debit method in the BankAccount. : import java.util.*; public class BankAccount { private String customerName; private double balance; private boolean frozen = false; private BankAccount() { } public BankAccount(String Name, double balance) { customerName = Name; this.balance = balance; } public String getCustomerName() { return customerName; } public double getBalance() { return balance; } public void setDebit(double amount) throws Exception { if (frozen) { throw...

  • This is my code for a TicTacToe game. However, I don't know how to write JUnit...

    This is my code for a TicTacToe game. However, I don't know how to write JUnit tests. Please help me with my JUnit Tests. I will post below what I have so far. package cs145TicTacToe; import java.util.Scanner; /** * A multiplayer Tic Tac Toe game */ public class TicTacToe {    private char currentPlayer;    private char[][] board;    private char winner;       /**    * Default constructor    * Initializes the board to be 3 by 3 and...

  • In Java, you'll find that it contains several methods that have not yet been finished. For now, the methods contain...

    In Java, you'll find that it contains several methods that have not yet been finished. For now, the methods contain only a placeholder return value so that the code will compile. Fill in your own implementation. public class SomePracticeStringMethods { /* * returns true if c is a letter in the word "temple" or false otherwise */ public static boolean inTU(char c) { /* placeholder just so that the function * compiles. fill in your implementation here. * * there...

  • Using java fix the code I implemented so that it passes the JUnit Tests. MATRIX3 public...

    Using java fix the code I implemented so that it passes the JUnit Tests. MATRIX3 public class Matrix3 { private double[][] matrix; /** * Creates a 3x3 matrix from an 2D array * @param v array containing 3 components of the desired vector */ public Matrix3(double[][] array) { this.matrix = array; } /** * Clones an existing matrix * @param old an existing Matrix3 object */ public Matrix3(Matrix3 old) { matrix = new double[old.matrix.length][]; for(int i = 0; i <...

  • Write a class called RationalNumber that represents a fraction with an integer numerator and denominator. A...

    Write a class called RationalNumber that represents a fraction with an integer numerator and denominator. A RationalNumber object should have the following methods: public RationalNumber(int numerator, int denominator) Constructs a new rational number to represent the ratio (numerator/denominator). The denominator cannot be 0, so throw an IllegalArgumentException if 0 is passed. public RationalNumber() Constructs a new rational number to represent the ratio (0/1). public int getDenominator() Returns this rational number’s denominator value; for example, if the ratio is (3/5), returns...

  • I need help with todo line please public class LinkedList { private Node head; public LinkedList()...

    I need help with todo line please public class LinkedList { private Node head; public LinkedList() { head = null; } public boolean isEmpty() { return head == null; } public int size() { int count = 0; Node current = head; while (current != null) { count++; current = current.getNext(); } return count; } public void add(int data) { Node newNode = new Node(data); newNode.setNext(head); head = newNode; } public void append(int data) { Node newNode = new Node(data);...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT