5/15/2018

BCS2233 OOP. Lab 16 May 2017 (Java FX)

Rewrite and run a Java program as listing 14.1, 14.2,14,3 and 14.4.




BCS2233 OOP. Lab 16 May 2017 (Inheritance)

1. Create a base class named Point consisting of x and y data members representing point coordinates. From this class, derive a class named Circle with another data member named radius. For this derived class, the x and y data members represent a circle’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 area() method that return 0.

The derived class should has an override method named area() that return’s a circle area.
Area = 3.14 x radius2.

 Draw UML diagram for the class Point and class Circle and then implement the class. Write a test program that creates one Point object and one Circle object with x 5, y 7 and radius 13. Display x and y for Point Object; x, y and radius for Circle Object.

2.  Create a class named Rectangle that contains data fields for height and length and a method named getArea() that returns the area of this Rectangle. Create a child class (derived from Rectangle) named Cube. Cube contains an additional data field named depth, and a getArea() method that overrides the parent method. Draw the UML diagram for the class (Class Rectangle and Class Cube) and then implement the class. Write a test program that creates one Rectangle object with height 4 and length 40 and one Cube object height 15, length 20 and depth 45. Display height, length and area of each object.

5/07/2018

BCS 2233 Object Oriented Programming (BIMB DEC)

Berikut adalah bahan-bahan pengajaran untuk subjek BCS 2233 Object Oriented Programming.

1) 'Lesson Plan' / Rancangan Pengajaran.

BIBM
2) Buku Rujukan Y. Daniel Liang, Introduction to Java™ Programming, Brief Version, 11th Edition. 2017. Pearson Education. 


3) 'Power point slide' bagi buku di atas boleh di dapati dari sini. Jumlah "Chapter" yang tersedia adalah sebanyak 42 "Slide", namun hanya Chapter di bawah sahaja yang terlibat. Pelajar di sarankan untuk membawa bahan ini (samada buku atau slide yang di cetak) ke kelas.


Chapter 1 Introduction to Computers, Programs, and Java 
Chapter 2 Elementary Programming 
Chapter 3 Selections 
Chapter 5 Loops 
Chapter 6 Methods 
Chapter 9 Objects and Classes 
Chapter 10 Thinking in Objects 
Chapter 11 Inheritance and Polymorphism
Chapter 14 JavaFX Basics

Beberapa bahan seperti koding Java yang terdapat di dalam buku ini boleh di dapati daripada sumber berikut.


4. Perisian
Dua jenis Perisian yang perlu ada untuk membangunkan program Java iaitu Enjin Java (JDK)  
 
dan Editor untuk menulis program java seperti  Jcreator atau Eclipse atau Netbean.
 
 
 

5/06/2018

DCT2023 DS & FP. Lab Stack. (#2)

3. A letter means push and an asterisk means pop in the following sequence.   
Give the sequence of values returned by the pop operations when this sequence 
of operations is performed on an initially empty LIFO stack.
 
         E A S * Y * Q U E * * * S T * * * I O * N * * *


4. A letter means push and an asterisk means pop in the following sequence.   
Give the contents of s[0], ..., s[4] after the execution of 
Program.
 
         L A * S T I * N * F I R * S T * * O U * T * * * * * * 

5/01/2018

BCS2233 OOP. Assignment III

Design a class named Account that contains:

       I.           A private int data field named id for the account (default 0).
     II.           A private double data field named balance for the account (default 0).
    III.           A private double data field named annualInterestRate that stores the cur-rent interest rate (default 0). Assume all accounts have the same interest rate.
   IV.           A private Date data field named dateCreated that stores the date when the account was created.
     V.           A no-arg constructor that creates a default account.
   VI.           A constructor that creates an account with the specified id and initial balance.
  VII.           The accessor and mutator methods for id,balance, and annualInterestRate.
 VIII.           The accessor method for dateCreated.
   IX.           A method named getMonthlyInterestRate() that returns the monthly interest rate.
     X.           A method named getMonthlyInterest() that returns the monthly interest.
   XI.           A method named withdraw that withdraws a specified amount from the account.
  XII.           A method named deposit that deposits a specified amount to the account.

Draw the UML diagram for the class and then implement the class.
(Hint: The  methodgetMonthlyInterest() is to return monthly interest, not the interest rate. Monthly interest is balance*monthlyInterestRate.monthlyInterestRate isannualInterestRate/12. Note that annualInterestRate is a percentage, e.g., like 4.5%. You need to divide it by 100.). Write a test program that creates an Account object with an account ID of 1122, a balance of $20,000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2,500, use the deposit method to deposit $3,000, and print  the balance, the monthly interest, and the date when this account was created.

BCS2233 OOP. Lab 16 May 2017 (Java FX)

Rewrite and run a Java program as listing 14.1, 14.2,14,3 and 14.4.