Note that there are some explanatory texts on larger screens.

plurals
  1. POBasic Object Oriented Programming
    text
    copied!<p>I am currently studying Java and have been asked to write a program that deals with actors and films as classes. </p> <p>The actor class has the following attributes: <br> <code>Name, Address, age, myFilm</code> (an array or arraylist to hold all the films a particular actor has starred in.</p> <p>The film class has these attributes:<br> <code>Name, Code</code> (String, String)</p> <p>I have implemented these classes with getter and setter methods to handle the data:<br> My actor class so far: </p> <pre><code>public class actor { private String name; private String address; private int age; int[] myFilms = new int[3]; public actor (String name, String address, int age) { } public void setName (String name) { this.name = name; } public void setAddress (String address) { this.address = address; } public void setAge (int age) { this.age = age; } public void setFilm () { } public String getName () { return name; } public String getAddress () { return address; } } </code></pre> <hr> <p>My film class:</p> <pre><code>public class film { private String name; private String code; //Constructor public film () { } public void setName (String name) { this.name = name; } public String getName (){ return name; } public String getCode (String name) { //Get code: //Split Function String[] words = name.split("\\s+"); String code = ""; for (int i=0; i &lt; words.length; i++) { code = code + words[i].charAt(0); code = code.toUpperCase(); } return code; } } </code></pre> <p>I'm hitting a brick wall with how to approach making the program dynamic to display each actors total films. This is for a college assingnment and I am also required to do a deep copy of the array at some point. I am almost completely new to OO so this is proving a tricky task for me.</p> <p>Any words of advice or a point in the right direction would be hugely appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload