Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please I need help, I did write my code but it keeps on showing me mistakes 7.12 LAB: Artwork label (classes/constructors) Given maino, define the
please I need help, I did write my code but it keeps on showing me mistakes
7.12 LAB: Artwork label (classes/constructors) Given maino, define the Artist class (in file Artist java) with constructors to initialize an artist's information get methods, and a toString method. The default constructor should initialize the artist's name to "None" and the years of birth and death to 0.toString() should return Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise Define the Artwork class (in file Artwork.java) with constructors to initialize an artwork's information, get methods, and a toString() method The constructor should by default initialize the title to "None', the year created to 0. Declare a private field of type Artist in the Artwork class Ex. If the input is Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921 ENG 54 PM INTL 2/10/2021 O 8! Type here to search Help/FAQ 0 Annicette Ndont Pablo Picasso 1881 1973 Three Musicians 1921 the output is Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921 If the input is Brice Marden 1938 -1 Distant Muses 2000 the output is Artist: Brice Marden, born 1938 Title: Distant Muses, 2000 ENG 640 PM INTL /10/2021 09 91 Type here to search 1 2 4 5 7 8 File is marked as read only Current file: ArtworkLabel.java import java.ut 11. Scanner; 3 public class ArtworkLabel { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); 6 String userTitle, userArtistName; int yearCreated, userBirthYear, userDeathYear; 9 10 userArtistName = scnr.nextLine(); 11 userBirthYear = scnr.nextInt(); 12 scnr.nextLine(); 13 userDeathYear = scnr.nextInt(); scnr.nextLine(); 15 userTitle = scnr.nextLine(); 16 yearCreated = scnr.nextInt(); 17 18 Artist userArtist = new Artist(userArtistName, userBirthYear, userDeathYear); 19 20 Artwork newArtwork = new Artwork (userTitle, yearCreated, userArtist); 21 22 System.out.println(newArtwork): 14 for grading Relow type any need Current file: Artist.java Load default template public class Artist { // TODO: Declare private fields - artistName, birthYear, deathYear // TODO: Define default constructor // TODO: Define second constructor to initialize // private fields (artistName, birthYear, deathYear) // TODO: Define get methods: getName(), getBirthYear(), getDeathYear() 0 1 2 13 14} // TODO: Define toString() method If deathYear is -1, only return birthYear Run your program as often as you'd like, before submitting for grading. Below, type any needed then click Run program and observe the program's output in the Current file: Artwork.java Load default template. 1 public class Artwork { // TODO: Declare private fields title, yearCreated // TODO: Declare private field artist of type Artist // TODO: Define default constructor // TODO: Define get methods: getTitle(), getYearCreated // TODO: Define second constructor to initialize private fields (title, yearCreated, artist) 9 10 11 12 13 14 15 16 17 ) 18 // TODO: Define toString() method // toString should call artist.toString() in order to return both the artist and the artwork }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started