Results 1 to 2 of 2

Thread: return

  1. #1
    Sanna.1 is offline Member
    Join Date
    Feb 2012
    Posts
    5
    Rep Power
    0

    Default return

    PHP Code:
    import cs1.Keyboard;
    import java.util.Scanner;
    class Person 
    {
        private String name;
        private String persnr;
        private String adress;
        private int age;
    
        public Person(String _name, String _persnr, String _adress, int _age) 
        {
            name = name;
            persnr = persnr;
            adress = adress;
            age = age;
        }
        
        public void byterNamn(String _name)
        {
            name = _name;
        }
        
        public void byterAdress(String _adress)
        {
            adress = _adress;
        }
        
        public void fyllerAr()
        {
            age = age + 1;
        }
        
        public String hamtaNamn()
        {
            return name;
        }
        
        public String hamtaPersonnmmer()
        {
            return persnr;
        }
        
        public String hamtaAdress()
        {
            return adress;
        }
        
        public int hamtaAlder()
        {
            return age;
        }
        
        public String toString()
        {
        String _toString;
        _toString = "Namn: " + name + "\nÅlder: " + age;
        _toString = _toString +  "\nPersonnummer: " + persnr + "\nAdress: " + adress;
        return _toString;
        }
         
    	 public p1()
    	 {
    	   System.out.print("namn: ");
    		name = Keyboard.readString();    
    		
    		System.out.print( "adress: " );
    		String adress = Keyboard.readString();
    
    		System.out.print( "ålder: " );
    		Integer age = new Integer(); 
    		age.parseInt(Keyboard.readint());
    
    		System.out.print( "personnummer: " );
    		String persnr = Keyboard.readString();
    
    	 }
    	 public p2()
    	 {
    	   System.out.print("namn: ");
    		name = Keyboard.readString();    
    		
    		System.out.print( "adress: " );
    		String adress = Keyboard.readString();
    
    		System.out.print( "ålder: " );
    		Integer age = new Integer(); 
    		age.parseInt(Keyboard.readint());
    
    		System.out.print( "personnummer: " );
    		String persnr = Keyboard.readString();
    	 }
    	 
        public static void main(String[] args) 
        {
    	 	String name = Keyboard.readString();
    		String persnr = Keyboard.readString();
    		String adress = Keyboard.readString();
    		int age = Keyboard.readint(); 
    		Person p1 = new Person(name, age, adress, personnummer);
    		
    		String name = Keyboard.readString();
    		String persnr = Keyboard.readString();
    		String adress = Keyboard.readString();
    		int age = Keyboard.readint(); 
    		Person p2 = new Person(name, age, adress, personnummer);
    
        }
    }
    hello can anyone help me whit the return on p1 and p2 i can not get it to work

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: return

    i can not get it to work
    You'll have to be a lot more specific than that. Recommended reading: How to ask questions the smart way

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. return subtype
    By TheSheepeh in forum New To Java
    Replies: 3
    Last Post: 03-18-2011, 10:48 PM
  2. How to separate return value ??
    By doha786 in forum New To Java
    Replies: 1
    Last Post: 03-10-2010, 03:43 PM
  3. Using int/int, 7/5 would return 1
    By zoe in forum New To Java
    Replies: 2
    Last Post: 12-02-2008, 11:25 AM
  4. about 'return'.
    By helloworld in forum New To Java
    Replies: 9
    Last Post: 11-28-2008, 04:08 AM
  5. if..else..return
    By mqdias in forum New To Java
    Replies: 1
    Last Post: 08-10-2007, 04:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •