Since we have to state the minimum number of test assertions, we can assume we don't have to include the constructors, accessors (getters) & mutators (setters) in that.
That leaves 3 functions that we have to test:
This function has the following pattern:
if (3 conditions) // 3 conditions so 23 = 8 possibilities
{
-----------
if (1 condition) // 1 conditions so 21 = 2 possibilities
{……….}
-------
}
if (2 conditions) // 2 conditions so 22 = 4 possibilities
{
-----------
if (1 condition) // 1 conditions so 21 = 2 possibilities
{……….}
-------
}
Number of possibilities of nested if is multiplied and possibilities of standalone if’s are added to get total no. of possibilities
Therefore, total number of possibilities = 8*2 + 4*2 = 24
And Thus no. of test assertions required for render(int maxWidth) function = 24
Total no. of test assertions required for *unit testing of the give ADT = 1 + 1 + 24 = 26
Consider the following class: public class NumericValue { private double d; private static final String theValuekindName...
Provided code Animal.java:
public class Animal
{
private String type;
private double age;
public Animal(String aT, double anA)
{
this.type = aT;
if(anA >= 0)
{
this.age =
anA;
}
}
public String getType()
{
return this.type;
}
public double getAge()
{
return this.age;
}
}
Provided code Zoo.java:
public class Zoo {...
import java.util.Scanner; public class Cat { private String name; private Breed breed; private double weight; public Cat(String name, Breed breed, double weigth) { this.name = name; this.breed = breed; this.weight = weight; } public Breed getBreed() { return breed; } public double getWeight() { return weight; } //other accessors and mutators ...... } public class Breed { private String name; private double averageWgt; public Breed(String name,double averageWgt) { this.name = name; this.averageWgt= averageWgt; } public double getWeight() { return averageWgt;...
4. Command pattern //class Stock public class Stock { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public void buy(int quantity){ System.out.println(“BOUGHT: “ + quantity + “x “ + this); } public void sell(int quantity){ System.out.println(“SOLD: “ + quantity + “x “ + this); } public String toString() { return “Product [name=” + name + “, price=” + price + “]”; } } a. Create two command classes that...
public class Item implements Comparable { private String name; private double price; /** * Constructor for objects of class Item * @param theName name of item * @param thePrice price of item */ public Item(String theName, double thePrice) { name = theName; price = thePrice; } /** * gets the name * @return name name of item */ public String getName() { return name; } /** * gets price of item * @return price price of item */...
java code ============= public class BankAccount { private String accountID; private double balance; /** Constructs a bank account with a zero balance @param accountID - ID of the Account */ public BankAccount(String accountID) { balance = 0; this.accountID = accountID; } /** Constructs a bank account with a given balance @param initialBalance the initial balance @param accountID - ID of the Account */ public BankAccount(double initialBalance, String accountID) { this.accountID = accountID; balance = initialBalance; } /** * Returns the...
How to solve this problem?
Consider the following class : public class Store Public final double SALES TAX_RATE = 0.063B private String name; public Store(String newName) setName ( newName); public String getName () { return name; public void setName (String newName) { name = newName; public String toString() return "name: “ + name; Write a class encapsulating a web store, which inherits from Store. A web store has the following additional attributes: an Internet Address and the programming language in...
java code ========= public class BankAccount { private String accountID; private double balance; /** Constructs a bank account with a zero balance @param accountID - ID of the Account */ public BankAccount(String accountID) { balance = 0; this.accountID = accountID; } /** Constructs a bank account with a given balance @param initialBalance the initial balance @param accountID - ID of the Account */ public BankAccount(double initialBalance, String accountID) { this.accountID = accountID; balance = initialBalance; } /** * Returns the...
departmentstore: package departmentstorepkg; import java.util.ArrayList; public class DepartmentStore { private static final int DEFAULT_SIZE = 10; private StaffMember [] myEmployees; private int myNumberEmployees; private String myFileName; private StaffMember[] employee; public DepartmentStore (String filename){ myFileName = filename; myEmployees = employee; } public String toString(){ return this.getClass().toString() + ": " + myFileName; } public void addEmployee(Employee emp){ } /** * prints out all the employees in the array list held in this class */ public void print(){ for(int i =...
public class q2 { public double d; public q2(double d) { this.d = d; } public double calculate(int i) { if (i < 0) { double m = i * ; * d; System.out.println("d (calculate) == " + d); } else { d = i * d; System.out.println("d (calculate) == " + d); } return d; } The following classes named q2 and test are given. What is the value of the variable resA after successfully running the program? public...
import java.util.Scanner; public class StudentClient { public static void main(String[] args) { Student s1 = new Student(); Student s2 = new Student("Smith", "123-45-6789", 3.2); Student s3 = new Student("Jones", "987-65-4321", 3.7); System.out.println("The name of student #1 is "); System.out.println("The social security number of student #1 is " + s1.toString()); System.out.println("Student #2 is " + s2); System.out.println("the name of student #3 is " + s3.getName()); System.out.println("The social security number...