Results 1 to 4 of 4
  1. #1
    akhmad is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default [B] I have done assignment about Interface, but I am not sure is it ok or not? [/B]

    I have done my assignment about interface, but I don't know is it ok or not, please could anyone help me?
    assignment is:
    Project Module - Object Oriented Programming/Interface
    1. Write a programme to print your name, qualification and the name of your college by implementing interfaces.
    ++++++++++++++++
    public interface People_Interface {

    // Methods Declaration to print your name, qualification and the name of your college.
    public void printName();
    public void printQualification();
    public void printCollegeName();

    }
    +++++++++++++++++
    public class Student_details implements People_Interface{

    public void printName(){
    System.out.println("My name is Josef");
    }
    public void printQualification(){
    System.out.println("My qualification is Bachelor's degree of IT");
    }
    public void printCollegeName(){
    System.out.println("College name is Al-Khorazmy");
    }

    }
    ++++++++++++++++++++
    public class Student {

    public static void main(String[] args) {

    People_Interface print = new Student_details();

    print.printName();
    print.printQualification();
    print.printCollegeName();

    }
    }
    +++++++++++++++++++++




    2. Modify the above programme by implementing separate interfaces to print:
    - Your Name
    - Your Age
    - Name of Your College
    - Just print the line "I am a Java Programmer


    In the above programme use the same main method to call different interfaces and print the output which should look like this:
    Output:
    My Name is : "Your Name"
    My Age is : "Your Age"
    My College is : "Your College's Name"
    I am a Java Programmer

    ++++++++++++++++++++++
    public class Printing implements Printing_Interface{

    public void printName(){
    System.out.print("My name is: ");
    }
    public void printAge(){
    System.out.print("My Age is: ");
    }

    public void printCollegeName(){
    System.out.print("My College is: ");
    }

    public void printIAmAJavaProgrammer(){
    System.out.println("I am a Java Programmer");
    }

    }
    +++++++++++++++++++++++++++++++
    public interface Printing_Interface {

    // Methods Declaration to print your name, qualification and the name of your college.
    public void printName();
    public void printAge();
    public void printCollegeName();
    public void printIAmAJavaProgrammer();

    }
    ++++++++++++++++++++++++++++++++++
    public class Student_details implements Student_Interface{

    private String name;
    private int age;
    private String collegeName;

    public void setName(String value){
    name = value;
    }

    public String getName(){
    return name;
    }

    public void setAge(int value){
    age = value;
    }

    public int getAge(){
    return age;
    }

    public void setCollegeName(String value){
    collegeName = value;
    }
    public String getCollegeName(){
    return collegeName;
    }

    }
    ++++++++++++++++++++++++++++++++++
    public interface Student_Interface {

    // Methods Declaration to print your name, qualification and the name of your college.
    public void setName(String value);
    public String getName();
    public void setAge(int value);
    public int getAge();
    public void setCollegeName(String value);
    public String getCollegeName();

    }
    +++++++++++++++++++++++++++++++++++
    public class Student {

    public static void main(String[] args) {

    Student_Interface student1 = new Student_details();

    student1.setName("Akhmad");
    student1.setAge(30);
    student1.setCollegeName("Al-Khorazmiy");

    Printing_Interface printing = new Printing();

    printing.printName();
    System.out.println(student1.getName());
    printing.printAge();
    System.out.println(student1.getAge());
    printing.printCollegeName();
    System.out.println(student1.getCollegeName());
    printing.printIAmAJavaProgrammer();
    }
    }
    +++++++++++++++++++++++++++++++++++++++
    Sorry about too much code, if anyone can help I really appreciate this
    regards
    Akhmad

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    What is your problem.
    Code reviewing is not really something that can be done here easily...many of us have real jobs.
    :)

  3. #3
    akhmad is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default

    Sorry about too much code again, if who got spare time or who is a new student like me, please help :), it is not for who is busy at work
    thx

  4. #4
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Surely your teacher gave you some idea of what the input/output and result should be after executing the program?

    We aren't in your class and don't have the time to take code samples and check if they're "okay." If your program does what your teacher wants, is properly documented, and provides the desired output, I don't see why it's not okay.

Similar Threads

  1. Need help with assignment! please
    By runawaykinms in forum Java Applets
    Replies: 2
    Last Post: 10-06-2010, 09:58 AM
  2. I am looking for help with an assignment
    By nanoo51969 in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 09:41 PM

Posting Permissions

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