Question: Programming Steps: (In Java) (Please screenshot your output) A. Files required or needed to be created: 1. Artist.java (Given Below) 2. p7artists.java (Input file to
Programming Steps: (In Java) (Please screenshot your output)
A. Files required or needed to be created: 1. Artist.java (Given Below) 2. p7artists.java (Input file to read from) 3. out1.txt (Output file to write to)
B. Java programs needed to writeand create: 1. MyArtistList.java: - Contains the following: 1. list - public, Arraylist of Artist. This list will contain all entries from "p7artists.txt"
2. Constructor: A constructor that accepts one string parameter which is the Input File Name, and will read the file to a ArrayList.
3. Two print() methods: i) First one takes two parameters : A heading(name) and the output file ID - to print the contents of list to the output file ii) No parameter: Print the list contents to the console
C. Construct Step1.java that contans only the following code: public class Step1 { public Step1() { MyArtistList myArtists = new MyArtistList("C:/Users/patel/Desktop/JavaFiles/p7artists.txt"); myArtists.print("Name", "C:/Users/patel/Desktop/JavaFiles/exam3out1.txt"); }
}
D. Construct "Main.java" that calls "Step1" which will produce an output file "out1.txt" that contains all ArtistID and ArtistName from "p7artists.txt".
E. Attach the output when answering.
Required files:
p7artists.txt:
1 Acconci 2 Budd 3 Carpenter 4 Dill 5 Edwards 6 Fleming 7 Garber 8 Higgins 9 Ibe 10 Kollasch 11 Lerman 12 Metz 13 Novarre 14 Ortega 15 Parker 16 Penn 17 Pierobon 18 Prinzen 19 Quiroz 20 Rath
Artist.java:
public class Artist implements java.lang.Comparable
/** * Constructor * * @param name * @param number */ Artist(String name, int number) { this.artistID = number; this.artistName = name; }
/** * Constructor * * @param artistID * @param artistName * @param art */ public Artist(int artistID, String artistName, Art art) { this.artistID = artistID; this.artistName = artistName; this.art = art; }
/** * return the artistName * * @return */ public String getArtistName() { return artistName; }
/** * set the artistName * * @param artistName */ public void setArtistName(String artistName) { this.artistName = artistName; }
/** * return the artistId * * @return */ public int getArtistID() { return artistID; }
/** * set the artistId * * @param artistId */ public void setArtistID(int artistId) { this.artistID = artistId; }
/** * @return the art */ public Art getArt() { return art; }
/** * @param art * the art to set */ public void setArt(Art art) { this.art = art; }
public int compareTo(Artist o) { return this.getArt().compareTo(o.getArt()); }
/** * toString method */ public String toString() { return String.format("%-9d %-20s", this.artistID, this.artistName); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
