Results 1 to 19 of 19

Thread: Java

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260

    Java

    :
    "Add a method in the class Student for displaying all information about the student."

    Code:
    package university;
    
    import university.Universities; //enumeration
    import university.Specialnost;; //enumeration
    
    public class Student {
    	
    	private String name;
    	private int course;
    	private Universities university;
    	private Specialnost specialnost;
    	private String mail;
    	private long phone;
    	private static int value=0;
    
    	String information(){
    		String inf ="Information for student :"+name+" "+course+" "+university+" "+specialnost+" "+mail+" "+phone;
    		return inf;
    	}
    	
    	
    	public Student (String name ,int course ,Universities university ,Specialnost specialnost,String mail,long phone ) {
    	this.name = name;
    	this.course = course;
    	this.university = university;
    	this.mail =mail;
    	this.phone=phone;
    	this.specialnost = specialnost ;
    
    }
    
    	public int nextvalue () {
    		value++;
    		return value;
    	}
    
    	public String getName() {
    		return name;
    	}
    
    	public void setName(String name) {
    		this.name = name;
    	}
    
    	public int getCourse() {
    		return course;
    	}
    	
    	public String toString(){
    		return Student.value+" "+name + ", "+course +", "+university +" ,"+specialnost + " ,mail:"+ mail +" ,tel:+"+phone;
    	}
    	
    	
    	
    	
    	public void setCourse(int course) {
    		this.course = course;
    	}
    
    	public Universities getUniversity() {
    		return university;
    	}
    
    	public void setUniversity(Universities university) {
    		this.university = university;
    	}
    
    	public long getPhone() {
    		return phone;
    	}
    
    	public void setPhone(long phone) {
    		this.phone = phone;
    	}
    
    	public Specialnost getSpecialnost() {
    		return specialnost;
    	}
    
    	public void setSpecialnost(Specialnost specialnost) {
    		this.specialnost = specialnost;
    	}
    
    	public String getMail() {
    		return mail;
    	}
    
    	public void setMail(String mail) {
    		this.mail = mail;
    	}
    }
    
    class printinformation {
    	public static void main(String args[]) {
    	Student inf = new Student();
    	String information;
    	information = inf.information();
    	System.out.println(information);
    	}	
    }
    :
    Student inf = new Student(); //The constructor Student() is undefined

    - .

  2. #2
    Exhumator's Avatar
    Join Date: Jan:2005
    Location: Sofia
    Posts: 14,687
    , ( ), default-, .

  3. #3
    Registered User idn's Avatar
    Join Date: May:2004
    Location:
    Posts: 491
    :

    public Student() {
    this(null, -1, null, null, null, -1);
    }

    Java.
    EP35-DS4 :: Pentium Q9550 :: 4x2GB DDRII :: GeForce 9800GT :: 2x320GB SATA :: DVD-ROM :: CMPSU-450VXEU

  4. #4
    Bombera's Avatar
    Join Date: Jul:2001
    Location: 4EVA
    Posts: 13,833
    . , . - . - new Student();

    .. , ,
    EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
    Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|

  5. #5
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260
    , ( ), default-, .
    Student inf = new Student(); //The constructor Student() is undefined
    , .

    .

    :

    public Student() {
    this(null, -1, null, null, null, -1);
    }

    Java.
    , .
    Last edited by bombov; 14th July 2008 at 12:34.

  6. #6
    Bombera's Avatar
    Join Date: Jul:2001
    Location: 4EVA
    Posts: 13,833
    , , main public . , .
    EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
    Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|

  7. #7
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260
    , , .

  8. #8
    WarLord's Avatar
    Join Date: May:2003
    Location:
    Posts: 129
    ? .
    .. phone - .

    Quote Originally Posted by bombov View Post
    , , .
    .
    Thou hast not to like it, thou hast just to do it.

  9. #9
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260
    Quote Originally Posted by WarLord View Post
    ? .
    .. phone - .


    .
    , .

  10. #10
    Exhumator's Avatar
    Join Date: Jan:2005
    Location: Sofia
    Posts: 14,687
    Quote Originally Posted by bombov View Post
    , .
    "" ...

  11. #11
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260
    Quote Originally Posted by Exhumator View Post
    "" ...
    , .

    .
    Java 2 - ( - ).
    .

    Code:
    class printinformation {
    	public static void main(String args[]) {
    	Student inf = new Student();
    	
    	String info;
    	
    	inf.name = "koko";
    	inf.course = 5;
    	inf.university = Universities.Tu_Varna;
    	inf.specialnost = Specialnost.KMM;
    	inf.phone = 235455;
    	inf.mail="gogo@mail.bg";
    	inf.value=0;
    	
    	
    	info = inf.toString();
    	System.out.println(info);
    	}	
    }
    , .
    Last edited by bombov; 14th July 2008 at 13:46.

  12. #12
    WarLord's Avatar
    Join Date: May:2003
    Location:
    Posts: 129
    Quote Originally Posted by bombov View Post
    , .
    .
    Thou hast not to like it, thou hast just to do it.

  13. #13
    Bombera's Avatar
    Join Date: Jul:2001
    Location: 4EVA
    Posts: 13,833
    , , :
    javac Student.java
    java Student
    Code:
    public class Student {
    	
    	private String name;
    	private int course;
    	private String mail;
    	private String phone;
    	private static int value=0;
    
    	String information(){
    		String inf ="Information for student: "+name+" "+course+" "+mail+" "+phone;
    		return inf;
    	}
    	
    	
    	public Student (String name,int course,String mail,String phone) {
    		this.name = name;
    		this.course = course;
    		this.mail =mail;
    		this.phone=phone;
    	}
    
    	public Student () {
    		this.name = "Unknown";
    		this.course = 0;
    		this.mail = "john@doe.com";
    		this.phone= "+0";
    	}
    	
    	public String toString(){
    		return Student.value +", name: "+name + ", course: "+ course + ", mail:"+ mail +", tel:" + phone;
    	}
    
    	public static void main(String args[]) {
    		Student inf = new Student();
    		Student inf2 = new Student("Koko Barbarian", 1, "koko@barbarians.com", "+359XXXYYYYYY");
    		System.out.println(inf.information());
    		System.out.println(inf2.information());
    	}
    	
    }
    EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
    Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|

  14. #14
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260
    @Bombera .

    @idn :
    1. , private public , .
    2. Java , - , , .
    Last edited by bombov; 14th July 2008 at 15:39.

  15. #15
    Registered User idn's Avatar
    Join Date: May:2004
    Location:
    Posts: 491
    , Java , Thinking in Java, - , , , .
    , , Google .
    EP35-DS4 :: Pentium Q9550 :: 4x2GB DDRII :: GeForce 9800GT :: 2x320GB SATA :: DVD-ROM :: CMPSU-450VXEU

  16. #16
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260
    .
    Last edited by bombov; 14th July 2008 at 16:42.

  17. #17
    Registered User
    Join Date: Apr:2008
    Location: sofia
    Posts: 160
    . .

  18. #18
    Registered User bombov's Avatar
    Join Date: Jan:2007
    Location:
    Posts: 260
    , , .

Posting Permissions

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

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |