#New to java and using gradle build - need some help with why my building is failing
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
package assignmentone;
/**
* This is Javadoc comment.
*/
public class Album {
// Declare private attributes
private String name;
private int releaseYear;
private String artist;
/**
* This is Javadoc comment.
*/
public Album(String name, int releaseYear, String artist) {
// Guard against improper values
if (name != null && name.length() >= 4) {
this.name = name;
} else {
this.name = "No name";
}
if (releaseYear >= 1800 && releaseYear <= 2029) {
this.releaseYear = releaseYear;
} else {
throw new IllegalArgumentException("Invalid releaseyear input");
}
if (artist != null) {
this.artist = artist;
} else {
this.artist = "No artist";
}
}
/**
* Setters and getters methods.
*/
public void setName(String newName) {
if (newName != null && newName.length() >= 4) {
this.name = newName;
} else {
this.name = "No name";
}
}
/**
* Returns the name of the album.
*
* @return the name of the album
*/
public String getName() {
return name;
}
/**
* Sets the release year of the album.
*/
public void setYear(int releaseYear) {
if (releaseYear >= 1800 && releaseYear <= 2029) {
this.releaseYear = releaseYear;
} else {
this.releaseYear = -1;
throw new IllegalArgumentException("Invalid releaseyear input");
}
this.releaseYear = releaseYear;
}
public int getYear() {
return releaseYear;
}
/**
* Sets the artist for this object.
*
* @param artist the name of the artist
*/
public void setArtist(String artist) {
if (artist != null) {
this.artist = artist;
} else {
this.artist = "No artist";
}
}
/**
* Returns the artist of the album.
*
* @return the artist of the album
*/
public String getArtist() {
return artist;
}
}
have you checked these testcases?
AlbumGeneratorTest > testAlbumGenerator() FAILED
java.lang.IllegalArgumentException at AlbumGeneratorTest.java:17
AlbumTest > testSetYearTooLow() FAILED
org.opentest4j.AssertionFailedError at AlbumTest.java:60
AlbumTest > testSetArtistToShort() FAILED
org.opentest4j.AssertionFailedError at AlbumTest.java:84
AlbumTest > testSetYearTooHigh() FAILED
java.lang.IllegalArgumentException at AlbumTest.java:67
it looks like that
Ok, so you do get why your build is failing?
not really
your build fails because some testcases fail
yeah i understand that but why...
the red text shows that, given the line you seemingly have an album with year -1
i knew what that meant and i corrected that before but it was still showing the same error
but i think i undersand what's causing the issue, thank u