Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Final Project using OOP not sure if im following proper design

  1. #1
    Member
    Join Date
    Mar 2013
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Final Project using OOP not sure if im following proper design

    so im working on a final project for my intro to java-oop class. We recently made the jump to OOP and its a bit confusing. This program needs to have 1 main class and 3 regular classes. its supposed to be a movie production program. It needs to have a initial investment as well as a cast and there budget then a box office return followed by the planning of a sequel with the budget for the sequel based on the box office return. Theres a little more to it but thats the idea. there should be two options for the cast which is actor, actress,director. I built a program and took it to class and basically though i was building some objects it was very much a structured program. So I started over and this is what I have right now
    Main class:
    public class MovieProducer {
    public static void main(String args[]){
     
    	Cast actor1 = new Cast ("Actor", "Tom Wise", 2000000);
    	Cast actress1 = new Cast ("Actress", "Lana Elles", 1000000);
    	Cast director1 = new Cast ("Director", "Mike Powers", 1500000);
     
    		double initInv= 5000000;// initial investment
    		double boxReturn= 4000000;
    		double actorCost = actor1.getCost();
    		double actressCost = actress1.getCost();
    		double directorCost = director1.getCost();
     
    	Account movie1 = new Account(initInv, boxReturn, actorCost, actressCost, directorCost);
     
    		System.out.println( "First Movie");
    		System.out.println( "");
    		System.out.println( "The role of: "+ actor1.printString());
    		System.out.println( "The role of: "+ actress1.printString());
    		System.out.println( "The role of: "+ director1.printString());
    		System.out.println( "");
    		System.out.println( "The Total cost of the crew is:  "+ movie1.AddCosts());
    		System.out.println( "The Initial Investment is:  "+ movie1.getInvestment());
    		System.out.println( "The Box office return is:  "+ movie1.getBoxReturn());
    		System.out.println( "The Gain or Loss on this movie is:  "+ movie1.Add());
    		System.out.println( "Your next Movie budget will be:  "+ movie1.NextBudget());
     
     
     
    	// Second movie object:
     
     
     	Cast actor2 = new Cast ("Actor", "Les Clay", 1000000);
    	Cast actress2 = new Cast ("Actress", "Amber May", 1000000);
    	Cast director2 = new Cast ("Director", "Bill Wes", 2000000);
     
    		double inv2 = movie1.NextBudget();// second investment
    		double boxReturn2= 4750000;
    		double actorCost2 = actor2.getCost();
    		double actressCost2 = actress2.getCost();
    		double directorCost2 = director2.getCost();
     
     	Account movie2 = new Account(inv2, boxReturn2, actorCost2, actressCost2, directorCost2);
    		System.out.println( "");
    		System.out.println( "Second Movie");
    		System.out.println( "");
    		System.out.println( "The role of: "+ actor2.printString());
    		System.out.println( "The role of: "+ actress2.printString());
    		System.out.println( "The role of: "+ director2.printString());
    		System.out.println( "");
    		System.out.println( "The Initial Investment is:  "+ movie2.getInvestment());
    		System.out.println( "The Total cost of the crew is:  "+ movie2.AddCosts());
     
    		System.out.println( "The Box office return is:  "+ movie2.getBoxReturn());
    		System.out.println( "The Gain or Loss on this movie is:  "+ movie2.Add());
    		System.out.println( "Your next Movie budget will be:  "+ movie2.NextBudget());
     
     
    	//Movie nextMovie= new Movie(actor1.getName(),actor2.getName(),actress2.getName(),director2.getName(),actor1.getCost(),actor2.getCost(),actress1.getCost(), director1.getCost(),movie1.getInvestment());
    }}

    Cast class:
     
    public class Cast {
    	String role;
    	String name;
    	double cost;
    // constructor
    Cast(String role, String name, double cost) {
    	this.role= role ;
    	this.name= name;
    	this.cost = cost;
     
    }
     
    // Get role
    public String getRole(){
       return role;
     
    }
     
    // Set Role.
    public void setRole(String tempRole){
       role = tempRole;
     
       }
    //Get name
    public String getName(){
       return  name;
     
    }
     
    // Set name.
    public void setName(String tempName){
       name = tempName;
     
       }
    //Get cost
    public double getCost(){
       return cost;
     
    }
     
    // Set cost.
    public void setCost(double tempCost){
       cost = tempCost;
     
       }
    String printString(){// 
    	 return ((role) + " will be cast with: " + (name)+" at a price of: $"+(cost));}
     
     
     
    }
    Account class:
    public class Account {
    	double invest;
    	double bOReturn;
    	double actorCost;
    	double actressCost;
    	double directorCost;
    	double nextBudget=0;
     
     
    // constructor
    Account(double invest, double bOReturn, double actorCost, double actressCost, double directorCost) {
    	this.invest= invest ;
    	this.bOReturn= bOReturn;
    	this.actorCost= actorCost;
    	this.actressCost= actressCost;
    	this.directorCost = directorCost;
    }
     
    // Get role
    public double getInvestment(){
    		return invest;
     
    }
     
    // Set Role.
    public void setInvestment(double tempInvest){
    	invest= tempInvest;
     
       }
    //Get role
    public double getBoxReturn(){
    		return bOReturn;
     
    }
     
    //Set Role.
    public void setBoxReturn(double tempBox){
    	bOReturn= tempBox;
     
    }
    double AddCosts(){
    	double remainBud= (actorCost+ actressCost + directorCost);
    		return remainBud;
    }
     
    double  Add(){
    	double gainOrLoss = (bOReturn)- (invest);
    		return gainOrLoss;
     
    }
    double NextBudget(){
     
    	if (bOReturn < invest){
    		nextBudget=bOReturn;}
    	else if(bOReturn > invest){
    			nextBudget=bOReturn;}
    				else {
    					nextBudget=invest;}
    					return nextBudget;}
     
    /*double decideActor(){
    	double actorFinal=0;
    	if( nextBud < (actorCost+ actressCost + directorCost) ){*/
    }

    Im not sure if im following oop design like im supposed to, and I dont want to go any further until i know if im doing it correctly, plus Im stuck on the next part so I wanted to get this correct. Any help or suggestion would greatly be apreciated


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Final Project using OOP not sure if im following proper design

    methods should begin with a lower case letter.
    methods should "do one thing".. I see methods that adjust values of variables and return values, that is more like two different jobs. Getters and setters are generally used for adjusting values of variables (or by directly accessing the variable). Some methods here tend to set the variable and return the new value all in one method, like a getter and setter in one.
    printString() from Cast class really doesn't print anything as much as it returns a String. Could use a different name here.

    When writing the code for the class Cast and the class Account, write the method and variable names from the perspective of the person who will write the MovieProducer class. (The person "using" the Cast and Account classes) Any method or variable name should reflect what it will do for the person calling the method...
    getSomeValue() or setSomeValue(String newValue) or doLongMathOnBigNumbersInBackground(bigNumber, biggerNumber), I hope you get the idea

    Looks good so far

Similar Threads

  1. want to do a project with java on OOP need help
    By Sakib in forum Java Theory & Questions
    Replies: 1
    Last Post: March 21st, 2013, 12:06 PM
  2. JAVA1 - Final Project
    By ch103 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 12th, 2011, 02:48 PM
  3. Need Ideas For OOP(Java) Mini Project
    By rizwansheikh in forum Object Oriented Programming
    Replies: 6
    Last Post: December 13th, 2010, 01:47 PM
  4. final project idea
    By zulqar in forum AWT / Java Swing
    Replies: 4
    Last Post: November 3rd, 2010, 07:28 AM
  5. final project idea
    By zulqar in forum Java Theory & Questions
    Replies: 1
    Last Post: November 1st, 2010, 12:02 PM