Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Customer class with the following: Instance variables with appropriate getter and setter methods: name, which is a String, and a customerID, which is

Create a Customer class with the following:

Instance variables with appropriate getter and setter methods: name, which is a String, and a customerID, which is an integer.

A toString() method which provides a well-formatted string representation of the instance variables in the Customer class.

Appropriate constructors for the class.

import static org.junit.Assert.*;

import org.junit.Test;

public class CustomerIA3Test { // test constructors @Test public void testDefaultConstructor() { Customer c = new Customer(); assertEquals("Expected initial ID to be 0", 0, c.getID(), 0.00001); }

@Test public void testConstructorWithParams() { Customer c = new Customer("John Doe", 876); assertEquals("Expected name to be John Doe", "John Doe", c.getName()); assertEquals("Expected id to be 876", 876, c.getID(), 0.0001); } @Test public void testCopyConstructor() { Customer oldCustomer = new Customer("Alice Black", 314); Customer newCustomer = new Customer(oldCustomer); assertEquals("Expected name to be Alice Black", "Alice Black", newCustomer.getName()); assertEquals("Expected id to be 314", 314, newCustomer.getID(), 0.0001); } @Test public void test_toString_test1() { Customer c = new Customer("Alice Black", 314); assertEquals("Alice Black 314", c.toString()); } @Test public void test_toString_test2() { Customer c = new Customer("Mona Lisa", 61); assertEquals("Mona Lisa 61", c.toString()); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions