8.1.1. WrClasses-WE1-P1¶
Subgoals for Writing a Class 1/4
Name it
Differentiate class-level (static) vs. instance/object-level variables
Differentiate class-level (static) vs. instance/object behaviors/methods
Define class variables (static) as needed ‘
Name
Data Type
public / private / final
Define instance variables (that you want to be interrelated)
Name
Data Type
private
Classes-WE1-P1
Consider writing a class to represent a song on your phone or music player. You need to define the appropriate attributes (data) to store the name of the song, the artist, and length. All songs should be stored in the same format, which should be MP3.
Complete the following class skeleton.
public class SongType {
___A___ ___B___ title;
___C___ ___D___ artist;
___E___ ___F___ length;
___G___ ___H___ final String FORMAT = "MP3";
}
- public
- private
- String
- int
- double
Q1: Fill in Blank A.
- public
- private
- String
- int
- double
Q2: Fill in Blank B.
- public
- private
- String
- int
- double
Q3: Fill in Blank C.
- public
- private
- String
- int
- double
Q4: Fill in Blank D.
- public
- private
- String
- int
- double
Q5: Fill in Blank E.
- public
- private
- String
- int
- double
Q6: Fill in Blank F.
- public
- private
- static
- void
- const
Q7: Fill in Blank G.
- public
- private
- static
- void
- const
Q8: Fill in Blank H.