Results 1 to 19 of 19
Thread: Java
Hybrid View
-
14th July 2008 12:18 #1
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
- .
-
14th July 2008 12:23 #2
-
14th July 2008 12:25 #3
:
public Student() {
this(null, -1, null, null, null, -1);
}
Java.EP35-DS4 :: Pentium Q9550 :: 4x2GB DDRII :: GeForce 9800GT :: 2x320GB SATA :: DVD-ROM :: CMPSU-450VXEU
-
14th July 2008 12:26 #4
. , . - . - 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|
-
14th July 2008 12:26 #5, ( ), 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.
-
14th July 2008 12:35 #6
, , 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|
-
14th July 2008 12:58 #7
-
14th July 2008 13:10 #8
-
14th July 2008 13:17 #9
-
14th July 2008 13:20 #10
-
14th July 2008 13:34 #11
, .
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.
-
14th July 2008 13:23 #12
-
14th July 2008 13:57 #13
, , :
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|
-
14th July 2008 15:34 #14
@Bombera .
@idn :
1. , private public , .
2. Java , - , , .Last edited by bombov; 14th July 2008 at 15:39.
-
14th July 2008 16:12 #15
, Java , Thinking in Java, - , , , .
,
, Google .
EP35-DS4 :: Pentium Q9550 :: 4x2GB DDRII :: GeForce 9800GT :: 2x320GB SATA :: DVD-ROM :: CMPSU-450VXEU
-
14th July 2008 16:35 #16
.
Last edited by bombov; 14th July 2008 at 16:42.
-
16th July 2008 17:39 #17Registered User
Join Date: Apr:2008
Location: sofia
Posts: 160
. .
-
16th July 2008 22:25 #18




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in