Question

In: Computer Science

Create a class, called Song. Song will have the following fields:  artist (a string) ...

Create a class, called Song. Song will have the following fields:  artist (a string)  title (a string)  duration (an integer, recorded in seconds)  collectionName (a string) All fields, except for collectionName, will be unique for each song. The collectionName will have the same value for all songs. In addition to these four fields, you will also create a set of get/set methods and a constructor. The get/set methods must be present for artist, title, and duration. Those fields should also be private. The collectionName can be public, and should be a single, shared value for all instances of Song. The constructor will take values for artist, title, and duration as arguments.

Solutions

Expert Solution

public class Song {
   private String artist;
   private String title;
   private int duration;
   public static String collectionName;
   public Song(){
       this.artist="";
       this.title="";
       this.duration=0;
   }
   public Song(String artist,String title,int duration){
       this.artist=artist;
       this.title=title;
       this.duration=duration;
   }
   public String getArtist() {
       return artist;
   }
   public void setArtist(String artist) {
       this.artist = artist;
   }
   public String getTitle() {
       return title;
   }
   public void setTitle(String title) {
       this.title = title;
   }
   public int getDuration() {
       return duration;
   }
   public void setDuration(int duration) {
       this.duration = duration;
   }
  
  
}


Related Solutions

Create a class named Horse that contains the following data fields: name - of type String...
Create a class named Horse that contains the following data fields: name - of type String color - of type String birthYear - of type int Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field, races (of type int), that holds the number of races in which the horse has competed and additional methods to get and set the new field. ------------------------------------ DemoHorses.java public class DemoHorses {     public static void...
Create a class called Dishwash with a double called CubicFeet, a string called color, and a...
Create a class called Dishwash with a double called CubicFeet, a string called color, and a method called Washing. The Washing method should return a string to the main class with the text "Now washing dishes!" In the main class create an array of DishWasher size 3. Give each DishWasher a different color and CubicFeet. Use a foreach loop to display that info, call the Washing method, and display the text returned from the Washing method call. c#
Using C# Create a class called Artist that contains 4 pieces of information as instance variables:...
Using C# Create a class called Artist that contains 4 pieces of information as instance variables: name (datatype string), specialization – i.e., music, pottery, literature, paintings (datatype string), number of art items (datatype int), country of birth (datatype string). Create a constructor that initializes the 4 instance variables. The Artist class must contain a property for each instance variable with get and set accessors. The property for number should verify that the Artist contributions is greater than zero. If a...
Create a class named “Car” which has the following fields. The fields correspond to the columns...
Create a class named “Car” which has the following fields. The fields correspond to the columns in the text file except the last one. i. Vehicle_Name : String ii. Engine_Number : String iii. Vehicle_Price : double iv. Profit : double v. Total_Price : double (Total_Price = Vehicle_Price + Vehicle_Price* Profit/100) 2. Write a Java program to read the content of the text file. Each row has the attributes of one Car Object (except Total_Price). 3. After reading the instances of...
Java... Design a Payroll class with the following fields: • name: a String containing the employee's...
Java... Design a Payroll class with the following fields: • name: a String containing the employee's name • idNumber: an int representing the employee's ID number • rate: a double containing the employee's hourly pay rate • hours: an int representing the number of hours this employee has worked The class should also have the following methods: • Constructor: takes the employee's name and ID number as arguments • Accessors: allow access to all of the fields of the Payroll...
Create a struct MenuItem containing fields for name (a string) and price (a float) of a...
Create a struct MenuItem containing fields for name (a string) and price (a float) of a menu item for a diner. Create a ReadItem() function that takes an istream and a MenuItem (both by reference) and prompts the user for the fields of the MenuItem, loading the values into the struct's fields. Create a PrintItem() function that takes an output stream (by reference) and a MenuItem (by value) and prints the MenuItem fields to the stream in a reasonable one-line...
with PHP Create a class called Employee that includes three instance variables—a first name (type String),...
with PHP Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary int). Provide a constructor that initializes the three instance data member. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its 0. Write a test app named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary....
You have a table called scholar where there are two fields id and create date. You...
You have a table called scholar where there are two fields id and create date. You want to create an ETL process that loads the data from scholar table into the big data platform. What are the different things that you will put on a requirement document for the developer to write code and implement the solution?
Suppose we have a Java class called Person.java public class Person { private String name; private...
Suppose we have a Java class called Person.java public class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName(){return name;} public int getAge(){return age;} } (a) In the following main method which lines contain reflection calls? import java.lang.reflect.Field; public class TestPerson { public static void main(String args[]) throws Exception { Person person = new Person("Peter", 20); Field field = person.getClass().getDeclaredField("name"); field.setAccessible(true); field.set(person, "Paul"); } }...
Create a file called grocery.ts. It should have a definition of a class with the obvious...
Create a file called grocery.ts. It should have a definition of a class with the obvious name Grocery. The class should have some basic attributes such as name, quantity, etc. Feel free to add any other attributes you think will be necessary. Add few grocery items to an array of groceries, such as milk, bread, and eggs, along with some quantities (i.e. 3, 6, 11). Display these grocery items as HTML output. The output of this assignment will be grocery.ts...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT