Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Problem packaging object oriented code

$
0
0
Just wrote a very messy, but effective code to gather information for three employees. I'll paste the main method code, not sure if I need to post the constructors too, which would make for an extremely long post, but how can I manipulate my main method code to make it into a package?

import employee.*;
import java.util.Scanner;

public class employeeInformation
 {

	public static void main ( String [ ] args ) {
	
	for (int i = 1; i <=3; i++) {

	   System.out.println ( "Enter the " + i + " employee's information" );
	   System.out.println ( );
	
	   Scanner scan = new Scanner (System.in);
	   employeeName name1 = new employeeName ( );

	   System.out.println ( "Enter the employee's name" );
	   String name = scan.nextLine ( );
	   System.out.println ( );
	
	   name1.setName ( name );


	   employeeName number1 = new employeeName ( );
	   System.out.println ( "Enter the employee's number" );
	 
	  int number = scan.nextInt ( );
	   System.out.println ( );
	
	   number1.setNumber ( number );

	    

 	   Address state1 = new Address ( );

	   System.out.println ( "Enter the state" );
	   String state = scan.nextLine ( );
	   System.out.println ( );

	
	   state1.setState ( state );

	   System.out.println ( );
	   String fill = scan.nextLine ( );
	   System.out.println ( );
  	

	   Address street1 = new Address ( );

	   System.out.println ( "Enter the street address" );
	   String street = scan.nextLine ( );
	   System.out.println ( );
	
	   street1.setStreet ( street );
 
	    

	    Address city1 = new Address ( );

	   System.out.println ( "Enter the city" );
	   String city = scan.nextLine ( );
	   System.out.println ( );
	
	   city1.setCity ( city );
 
	   

	   Address zip1 = new Address ( );

	   System.out.println ( "Enter the zipcode" );
	   int zip = scan.nextInt ( );
	   System.out.println ( );
	
	   zip1.setZip ( zip );

	   Date month1 = new Date ( );

	   System.out.println ( "Enter the month for hire (1 (Jan)" );
	   int month = scan.nextInt ( );
	   System.out.println ( );

	   month1.setMonth ( month );
 	
	  Date day1 = new Date ( );

	   System.out.println ( "Enter the day for hire"  );
	   int day = scan.nextInt ( );
	   System.out.println ( );

	   day1.setDay ( day );

	  Date year1 = new Date ( );

	   System.out.println ( "Enter the year for hire"  );
	   int year = scan.nextInt ( );
	   System.out.println ( );

	   year1.setYear ( year );
	   
	  System.out.println ( "Employee " + i + "data" );
	   System.out.println ( "The employee's name is " + name);
	   System.out.println ( ); 
	   System.out.println ( "The employee's number is " + number);
	   System.out.println ( );
	   System.out.println ( "The employee's state is " + state);
	   System.out.println ( );
	   System.out.println ( "The employee's street is " + street);
	   System.out.println ( );
	   System.out.println ( "The employee's city is " + city); 
	   System.out.println ( );
	   System.out.println ( "The employee's zipcode is " + zip);
	   System.out.println ( );
	   System.out.println ( "The hire date is: " +month + " / " + day + " / " +year);
	}
	
  
	
	}
}

	   

Viewing all articles
Browse latest Browse all 51036

Trending Articles