6/25/2016

15/16 SEM 1 DCT1093 OOP

DCT1093 Object Oriented Programming

Pelajar Diploma Information Technology (DIT) akan mengambil subjek Object Oriented Programming (di sebut OOP).

Berikut adalah bahan-bahan pengajaran bagi subjek berkenaan:-

1) Perancangan Pengajaran

  ' Lesson Plan  '

 


2) Buku Rujukan 
Y. Daniel Liang, Introduction to Java™ Programming, Brief Version, 9 Edition. 2013. Pearson Education. Sila cari di perpustakaan TATIUC, pelajar boleh samada menggunakan edisi 9 atau edisi 8. 'Power point slide boleh di dapati dari link di sini.

Hanya 'chapter' berikut sahaja yang termasuk dalam silibus:-
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 8
Chapter 10
Chapter 11
Chapter 13

4. Perisian

 Bagi membangunkan aplikasi java dalam pc masing-masing . Pelajar perlu melakukan 'installation' JDK (java development kit) dan mana-mana editor untuk java (seperti JCreator, NetBeans, Eclipse, BlueJ ).

5. Tutorial (Video)
Sila bawa 'pen drive' . Saiz hampir 1GB.

5. Contoh Penilaian
Quiz
Assignment
Test
Final Exam

5/08/2016

BCS2233: Inheritance Exercise


Create a base class named Point consisting of x and y data members representing point coordinates. From this class, derive a class named Sphere with another data member named radius. For this derived class, the x and y data members represent a sphere’s centre coordinates. The member method of the Point class should consist of a constructor that set the value for x and y to 0, an volume() method that return 0, and distance() method that returns the distance between two points, (x1,y1) and (x2,y2), where



Additionally, the derived class should has an overided method named volume() that return’s a Sphere volume

Volume = (4/3) × 3.14 × radius³


Draw UML diagram for the class Point and class Sphere.

4/24/2016

BCS2233 OOP: Test 1

Date:  28 April 2016
Time : 11:00-12:30

1. Which of the following are invalid identifiers, why?
I.    DCIT
II.    DCIT   Students
III.    $matric
IV.    matric_number
V.    1stJAVAProgram


2. Show ‘Evaluation Tree’ for the following expressions:
I.    8 + 2 / 4
II.    6 * 2 + 3 % 2
III.    3 + 2 / 5 + -2 * 4
IV.    2 * (1 + -(3/4) / 2) * (2 - 6 % 3)

3. Write a java fragment for the following problems.


0.    Write a for statement to print integer 1 to 20. [example]

int I;
For (i=1; i<=20; i++)
System.out.Println(i);


I.    Write a for statement to print integer 1 to 10.



II.    Write a while statement to print integer 1 to 10.




4.    Write a an algorithm and a java program that displays the following table:-
 (note that 1 kilogram is 2.2 pounds):

    Kilograms     Pounds  
    1             2.2     
    3             6.6     
    ...
    100           220  

4/23/2016

BCS2233 OOP: Assignment 3.


 Assignment 3

(The MyPoint class) Design a class named MyPoint to represent a point with x and y-coordinates. The class contains:
            I.     Two data fields x and y that represent the coordinates.
          II.     A no-arg constructor that creates a point (0, 0).
        III.     A constructor that constructs a point with specified coordinates.
          IV.     Two get methods for data fields x and y, respectively.
            V.     A method named distance that returns the distance from this point to another point of the MyPoint type.
          VI.     A method named distance that returns the distance from this point to another point with specified x and y-coordinates.
Draw the UML diagram for the class. Implement the class. Write a test program that creates two points (0, 0) and (10, 30.5) and displays the distance between them.


Due date:  8 Mei 2016

BCS2233 OOP: Thinking in Objects

Berikut adalah program untuk mengira BMI dan menyatakan status yang sepadan. Tukarkan kepada kaedah OOP.

import java.util.Scanner;

public class ComputeAndInterpretBMI {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    
    // Prompt the user to enter weight in pounds
    System.out.print("Enter weight in pounds: ");
    double weight = input.nextDouble();
    
    // Prompt the user to enter height in inches
    System.out.print("Enter height in inches: ");
    double height = input.nextDouble();
    
    final double KILOGRAMS_PER_POUND = 0.45359237; // Constant
    final double METERS_PER_INCH = 0.0254; // Constant 
    
    // Compute BMI
    double weightInKilograms = weight * KILOGRAMS_PER_POUND; 
    double heightInMeters = height * METERS_PER_INCH; 
    double bmi = weightInKilograms / 
      (heightInMeters * heightInMeters);

    // Display result
    System.out.println("BMI is " + bmi);
    if (bmi < 18.5)
      System.out.println("Underweight");
    else if (bmi < 25)
      System.out.println("Normal");
    else if (bmi < 30)
      System.out.println("Overweight");
    else
      System.out.println("Obese");
  }
}
 
--------------------------Cara 1----------------------------------------
import java.util.Scanner;
class BMI{
double weight,height;

void getinput(){
 Scanner input = new Scanner(System.in);
    
    // Prompt the user to enter weight in pounds
    System.out.print("Enter weight in pounds: ");
     weight = input.nextDouble();
    
    // Prompt the user to enter height in inches
    System.out.print("Enter height in inches: ");
     height = input.nextDouble();
    
}

 double tukarpoundtokilo(){
final double KILOGRAMS_PER_POUND = 0.45359237; // Constant
return ( weight * KILOGRAMS_PER_POUND);
}

 double tukarinchtometer(){
 final double METERS_PER_INCH = 0.0254; // Constant 
 
return (height * METERS_PER_INCH); 
}

 void printoutput(){
 double bmi;
 bmi= tukarpoundtokilo() / (tukarinchtometer() * tukarinchtometer());

    // Display result
    System.out.println("BMI is " + bmi);
    if (bmi < 18.5)
      System.out.println("Underweight");
    else if (bmi < 25)
      System.out.println("Normal");
    else if (bmi < 30)
      System.out.println("Overweight");
    else
      System.out.println("Obese");
}

}
 
public class carapertama {
    
    public static void main(String[] args) {
     
     BMI yourBMI = new BMI();
     yourBMI.getinput();
     yourBMI.printoutput();
     
    }
}
 

4/17/2016

BCS2233 OOP: Exercise Class


Write a class for each of the following specifications. In each case, include a constructor that set each member values to 0 and a member method named showdata() that can be used to display member values.


i) A class named rectangle that has double data members named width, height, and color.       
                      
ii) A class named time that has integer data members named hour, minute and second.


BCS2233 OOP. Procedural vs. Object-Oriented Programming (OOP)

The difference between the two styles of programming 

//Procedural
 
import java.util.Scanner;
public class calculateAreadanPerimeterofBox {
   
    public static void main(String[] args) {
                Scanner input= new Scanner(System.in);
                System.out.println("Sila Masukkan nilai tinggi dan lebar segiempat!");
        int tinggi = input.nextInt();
        int lebar =input.nextInt();
       
        int luasSegiempat=tinggi*lebar;
        int perimeterSegiEmpat = 2*(tinggi+lebar);
       
        System.out.println("Luas Segi Empat=" +luasSegiempat );
        System.out.println("Perimeter Segi Empat=" +perimeterSegiEmpat );

    }
}



// Object-Oriented Programming (OOP)

import java.util.Scanner;
 class segi4{
 int tinggi;
   int lebar;
  
   void getInput(){
                               Scanner input= new Scanner(System.in);
                               System.out.println("Sila Masukkan nilai tinggi dan lebar segiempat!");
                               tinggi = input.nextInt();
                               lebar =input.nextInt();
   }
  
   int kiraLuasSegiempat(){
                               return tinggi* lebar;
   }
  
   int kiraPerimeterSegiempat(){
                return 2*(tinggi+ lebar);
   }
  
   void printOutput(){
        System.out.println("Luas Segi Empat=" +kiraLuasSegiempat() );
        System.out.println("Perimeter Segi Empat=" +kiraPerimeterSegiempat() );
   }
 }
public class calculateAreadanPerimeterofBox2 {
  
    public static void main(String[] args) {
               
                segi4 segiEmpat1 = new segi4();
                segiEmpat1.getInput();
                segiEmpat1.printOutput();
    }
}
 

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...