Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Follopw instructions to define Invoice class. The attributes are private but not final. Define required 4 setters and 4 getters. The InvoiceTest class should contain

Follopw instructions to define Invoice class. The attributes are private but not final. Define required 4 setters and 4 getters. The InvoiceTest class should contain a main method so the JVM can run it. In the main method, create an object of Invoice. Call and display that object's details and invoiceTotal. And then set its attributes with some new values, display its updated details including invoice total.package Invoice;
public class Invoice {
private final String partNumber;
private final String partDescription;
private final int quantity;
private final double pricePerItem;
public Invoice(String partNumber, String partDescription, int quantity, double pricePerItem){
this.partNumber = partNumber;
this.partDescription = partDescription;
this.quantity = quantity;
this.pricePerItem = pricePerItem;
}
public double getInvoiceTotal(){
if (quantity <0){
return 0;
} else {
return quantity * pricePerItem;
}
}
// getters and setters for each attribute/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Invoice;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
*
* @author katra
*/
public class InvoiceTest {
public InvoiceTest(){
}
@BeforeAll
public static void setUpClass(){
}
@AfterAll
public static void tearDownClass(){
}
@BeforeEach
public void setUp(){
}
@AfterEach
public void tearDown(){
}
/**
* Test of getInvoiceTotal method, of class Invoice.
*/
@Test
public void testGetInvoiceTotal(){
System.out.println("getInvoiceTotal");
Invoice instance = null;
double expResult =0.0;
double result = instance.getInvoiceTotal();
assertEquals(expResult, result, 0.0);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}

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

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago