Question: Java - need help getting started. This program tracks the members of a cast on a TV show. Instructions: Create a class called CastList with

Java - need help getting started.

This program tracks the members of a cast on a TV show.

Instructions:

Create a class called CastList with these data members:

A private array of up to 5 Role objects

any other data members you may need

And these methods:

a method to add a Role object

a method to delete a Role object

a toString method that will print out the number of roles and the details of each role including the actors name and the characters name

In the main method of the Cast class, create a CastList object and add the roles we have have been using to this CastList object and print the entire CastList object.

---Actor.java----

package lesson2_3;

public class Actor {

private String name;

public Actor( String n){

name = n;

}

@Override

public String toString() {

return "Actor [name=" + name + "]";

}

}

---Cast.java---

package lesson2_3;

import java.io.PrintStream;

public class Cast {

static PrintStream syso = System.out;

public static void main(String[] args) {

int seasonf = 1;

Role r1 = new Role("Leslie Knope", "Amy Poehler", seasonf);

Role r2 = new Role("Ron Swanson", "Nick Offerman", seasonf);

int season2 = 2;

Role r3 = new Role("Ben Wyatt", "Adam Scott", season2);

syso.println(r1);

syso.println(r2);

syso.println(r3);

}

}

---Role.java---

package lesson2_3;

public class Role {

private String name;

private Actor actor;

private int startseason;

public Role( String n, String a, int start){

name = n;

actor = new Actor( a );

startseason = start;

}

@Override

public String toString() {

return "Role [name=" + name + ", " + startseason + " " + actor + "]";

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!