JAVA waddo endoooooo

Dhanuka Nilanjana

Active member
  • Aug 9, 2009
    700
    89
    28
    Dompe,Sri Lanka
    Write Abstract Data Type (ADT), class implementation and Demonstration classes (Like in the sample triangle example) for the following objects:
    a) Square
    b) Circle
    c) Student

    Write the get and set methods for the above classes with appropriate parameters/arguments.

    Create a separate class to demonstrate object creation and method calling for the above classes



    Meke Square Circle Student kiyana tunata package hadala karanna oni kiyala kiwwa mata hariyata terumak na ema karanne komada kiyala puluwan kenek balala help ekak denna (Package eka hadala eka programme eke coding ekata import karanna onilu).
    :(:(
     

    u_make_me_sick_

    Well-known member
  • Oct 1, 2011
    11,522
    7,320
    113
    ee kiyanne squre, student, circle kiyana java classes 3 wena wenama packages wala thiyenna oni kiyana eka,ee kiwwe ee classes 3 wena wenama folders wala thiyenna oni, okkoma eke thiyenna be. Abstract common class ekak ee folder 3 ta eliyen thiyanna,
    Oya code karanna use karanne IDE ekak da? ee kiwwe java code karanna puluwan application ekak da? such as eclipse, netbeans, intelij..wage ekak da? eewagen code karanawanam oya class nikamma import wenawa ctrl+shift+O gehuwama.
     

    Dhanuka Nilanjana

    Active member
  • Aug 9, 2009
    700
    89
    28
    Dompe,Sri Lanka
    ee kiyanne squre, student, circle kiyana java classes 3 wena wenama packages wala thiyenna oni kiyana eka,ee kiwwe ee classes 3 wena wenama folders wala thiyenna oni, okkoma eke thiyenna be. Abstract common class ekak ee folder 3 ta eliyen thiyanna,
    Oya code karanna use karanne IDE ekak da? ee kiwwe java code karanna puluwan application ekak da? such as eclipse, netbeans, intelij..wage ekak da? eewagen code karanawanam oya class nikamma import wenawa ctrl+shift+O gehuwama.

    Naha machan tanikarama coding karanna tiyenne heta assi submission anith programme okkoma hadala iwarai meka karanna teren na. :( :( :(
     

    Dhanuka Nilanjana

    Active member
  • Aug 9, 2009
    700
    89
    28
    Dompe,Sri Lanka
    therenne na banz
    Like in the sample triangle example me sample eka diyan..

    Ehema example ekak dunne naha ban u mama hitanne uta wadiya java ba kohen hari aran tamai mekath apita karanna dunne mama search kala internet eke eth naha ban. poddak indapan mama SinhaRuba hadala ewapu coding eka metana dannam


    package student;

    public class Student {
    private String firstName;
    private String lastName;
    private int age;
    private String address;
    public Student(String firstName, String lastName, int age, String address) {
    super();
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
    this.address = address;
    }
    public Student() {
    super();
    }
    public String getFirstName() {
    return firstName;
    }
    public void setFirstName(String firstName) {
    this.firstName = firstName;
    }
    public String getLastName() {
    return lastName;
    }
    public void setLastName(String lastName) {
    this.lastName = lastName;
    }
    public int getAge() {
    return age;
    }
    public void setAge(int age) {
    this.age = age;
    }
    public String getAddress() {
    return address;
    }
    public void setAddress(String address) {
    this.address = address;
    }
    @Override
    public String toString() {
    return "Student [firstName=" + firstName + ", lastName=" + lastName
    + ", age=" + age + ", address=" + address + "]";
    }


    }

    ============================

    then test class for student that outside the student package

    import student.Student;
    //import the student package

    public class TestApplication {

    public static void main(String[] args) {

    //u can set values like this or
    Student student = new Student("Amal","Perera",24,"Colombo");

    //this

    student.setFirstName("Kamal");
    student.setLastName("Silva");
    student.setAge(40);
    student.setAddress("Matara");


    System.out.println(student);
    }


    }
     

    DJvodka

    Well-known member
  • Mar 31, 2009
    3,375
    292
    83
    A land like no other
    package student;

    public class Student{

    }
    -------------------------------------
    package square;

    public class Square{

    //Write methods
    }
    ------------------------------------
    package circle;

    public class Circle{

    //Write methods

    }
    ------------------------------------
    import student.Student;
    import square.Square;
    import circle.Circle;
    public class A{
    public static void main(String args[]){
    Circle c = new Circle();
    Square s = new Square();
    Student st = new Student();
    ///Call methods using variables
    }}
     
    • Like
    Reactions: Dhanuka Nilanjana

    Dhanuka Nilanjana

    Active member
  • Aug 9, 2009
    700
    89
    28
    Dompe,Sri Lanka
    package student;

    public class Student{

    }
    -------------------------------------
    package square;

    public class Square{

    //Write methods
    }
    ------------------------------------
    package circle;

    public class Circle{

    //Write methods

    }
    ------------------------------------
    import student.Student;
    import square.Square;
    import circle.Circle;
    public class A{
    public static void main(String args[]){
    Circle c = new Circle();
    Square s = new Square();
    Student st = new Student();
    ///Call methods using variables
    }}


    Thanks macho got an idea
     

    u_make_me_sick_

    Well-known member
  • Oct 1, 2011
    11,522
    7,320
    113
    package student;

    public class Student{

    }
    -------------------------------------
    package square;

    public class Square{

    //Write methods
    }
    ------------------------------------
    package circle;

    public class Circle{

    //Write methods

    }
    ------------------------------------
    import student.Student;
    import square.Square;
    import circle.Circle;
    public class A{
    public static void main(String args[]){
    Circle c = new Circle();
    Square s = new Square();
    Student st = new Student();
    ///Call methods using variables
    }}

    meka thamay mamath kiwwe, mekata thawa Abstract class ekak danna shape kiyala, eeka anik packages athulata danne nethuwa eliyen thiyanna. anith student, circle, squre classes me abstract class eka extend karala hadanna>
    Eg : public abstract class Shape {

    abstract double getArea()
    { }

    abstract String getName()
    { }

    }

    public class Circle extends Shape{}

    eewage abstract methods override karala implement karanna.
    gemburu wedi da?
     

    DJvodka

    Well-known member
  • Mar 31, 2009
    3,375
    292
    83
    A land like no other
    meka thamay mamath kiwwe, mekata thawa Abstract class ekak danna shape kiyala, eeka anik packages athulata danne nethuwa eliyen thiyanna. anith student, circle, squre classes me abstract class eka extend karala hadanna>
    Eg : public abstract class Shape {

    abstract double getArea()
    { }

    abstract String getName()
    { }

    }

    public class Circle extends Shape{}

    eewage abstract methods override karala implement karanna.
    gemburu wedi da?

    Abstract class ekakin wenne common qualities thiyena classes logically eka wage use karana eka neda? Eka nisa Shape kiyal Abstract class ekakin student inherit karoth eke common qualities ne. Polymorphism implement karanawanam super interface ekak hadanna wenawa Eg: ICustomTypes kiyala.
    Eeta passe Shape kiyala interface ekak hadala eka super interface eken(ICustomTypes) extend karanawa. Den Student wa directly ICustomTypes interface eken implement karala Circle ekai Square ekai sub interface eken implement karanawa. Ethakota getArea() wage method ekak aniwaryen implement karanna ona Shape eke child kenek. Itapasse objects wala reference tika ICustomTypes walin gattanam polymorphism implement karanna puluwan. Eth oya thiyena assignment ekata echchara dura yanna one ne :P
     

    Dhanuka Nilanjana

    Active member
  • Aug 9, 2009
    700
    89
    28
    Dompe,Sri Lanka
    Abstract class ekakin wenne common qualities thiyena classes logically eka wage use karana eka neda? Eka nisa Shape kiyal Abstract class ekakin student inherit karoth eke common qualities ne. Polymorphism implement karanawanam super interface ekak hadanna wenawa Eg: ICustomTypes kiyala.
    Eeta passe Shape kiyala interface ekak hadala eka super interface eken(ICustomTypes) extend karanawa. Den Student wa directly ICustomTypes interface eken implement karala Circle ekai Square ekai sub interface eken implement karanawa. Ethakota getArea() wage method ekak aniwaryen implement karanna ona Shape eke child kenek. Itapasse objects wala reference tika ICustomTypes walin gattanam polymorphism implement karanna puluwan. Eth oya thiyena assignment ekata echchara dura yanna one ne :P


    Thanks bro