-2

Need test test code to test class Concert and getArtist.

error: method getArtist in class Concert cannot be applied to given types
required: java.lang.String
found: no arguments
reason: actual and formal argument lists differ in length
public Concert()
{
    int m = 9;
    int d = 8;
    int y = 2019;
    String a = new String("Jonas Brothers"); 
    String v = new String("Van Andel Arena");
    int totalSales = 0;
    getArtist(a);
}

public Concert (int m, int d, int y, String a, String v) 
{
    m = 9;
    d = 8;
    y = 2019;
    a = new String("Jonas Brothers"); 
    v = new String("Van Andel Arena");
    int totalSales = 0;
 }

public String getArtist(String a)
{
    return a;
}

/******************************************************
 * Test default constructor - no input parameters
 *****************************************************/
@Test
public void testDefaultConstructor() {
    Concert concert = new Concert();
    Assert.assertEquals("Artist name should be Jonas Brothers","Jonas Brothers", 
        concert.getArtist());
    Assert.assertEquals("Venue name should be Van Andel Arena","Van Andel Arena�", 
        concert.getVenue());
    Assert.assertEquals("Month should be 9",
        9, concert.getMonth());
    Assert.assertEquals("Day should be 8",
        8, concert.getDay());
    Assert.assertEquals("Year should be 2019",
        2019, concert.getYear());
    Assert.assertEquals("Available upper tickets should be 300",
        TOTAL_NUMBER_UPPER_TICKETS, concert.getAvailableUpperTickets());
    Assert.assertEquals("Available lower tickets should be 300",
        TOTAL_NUMBER_LOWER_TICKETS, concert.getAvailableLowerTickets());
    Assert.assertEquals("Available upper tickets should be 400",
        TOTAL_NUMBER_FLOOR_TICKETS, concert.getAvailableFloorTickets());
    Assert.assertEquals("total sales should be 0.0",
        0.0, concert.getTotalSales(),0.001);

}
Jee Mok
  • 6,157
  • 8
  • 47
  • 80
  • What line gives the error? Please label it in your code. – FailingCoder Oct 02 '19 at 23:56
  • 2
    I think that you need to learn what `fields` are. If you declared a variable within a method or constructor or other code block, it is limited in scope to that code block. – Scary Wombat Oct 03 '19 at 00:05
  • 1
    Also if you have a method like `public String getArtist(String a)` it means that it is expecting a paramater, so code like `concert.getArtist()` will not compile. – Scary Wombat Oct 03 '19 at 00:06
  • Example: https://stackoverflow.com/questions/215497/what-is-the-difference-between-public-protected-package-private-and-private-in/215505#215505 – FailingCoder Oct 03 '19 at 00:09

1 Answers1

-1

GetArtist method in Concert class is expecting a parameter which is missing in unit test calling code. Hence compilation fails.

vijay krishna
  • 177
  • 1
  • 7