Sunday, 21 October 2012

Lab 14- recursive -2013

Using recursive style , create a class that receive from a user a string and a number   then  have recursive  methods that :

1.  reverse the string recursively.  eg prog  become gorp
2.  count  the number of character in the screen recursively  eg.  prog = 4
3.  using a number entered , create a fibonacci  recursive  that return the result of that particular position of the number you entered.  eg 0 = 0 , 2 = 1 , 3 =3

Monday, 19 March 2012

LAB 03 July 2013 - Interface


Consider the following Printface interface, which is designed to standard printing status method for the class that implements it :

public interface Printface {
              public double goprint() ;
}

a) Write an abstract class CollegeMembers that implements Printface interface. This class also have a instance variable Name and ID. Goprint() is set as abstract method here and is not being implemented here.

b) Write a concrete subclass Lecturer that provide a concrete representation of the Collegemembers but does not provide any additional functionality . Implement Goprint() by printing the name and ID of the lecturer.

c) Write a concrete subclass Student that extends CollegeMembers and have additional instance variables passportno (string) , mykadno(string) and nationality (string) . Create necessary constructor for the class. This class should implement Goprint() based the rules below :
If nationality is not malaysian , print name, id and passport number
Else print name , id and mykadno

d) Create a driver class and write declarations for a reference lecturerA of type Lecturer and StudentB of type Student. Create new object for both class and refer the new objects by reference lecturerA and StudentB. Call both Goprint for each object.

Wednesday, 14 March 2012

P2 lab 1 2013

1. Create a class with at least 2 attribute  and 2 methods.
2. Inside the constructor , as for user input for your attributes.
3. Handle the exception correctly , throw it to the caller.
4. Create a driver class that create two object from the above class  ( 1 ) .

Monday, 5 March 2012

LAB 02 - july 2013 - Beginners ( still refreshing mode )

Do the following :

Question 1 :
------------------


  1. Create a class of Vehicles with appropriate properties and a method call accelerate(). In the accelerate() method print "Vehicle is Accelarating". Return nothing.
  2. Create a class of Car ( a subclass of vehicle ) with appropriate properties and methods call accelarate() and changegear(). Overide Accelarate() method by changing the implementation. Changegear method will ask user the gear number to change to , then print the new gear choosen and accelarate.
  1. Create a GearException class that will be thrown if the user choose the gear number < 1 or > 5 . Create appropriate message.Implement Try and catch block where necessary.Print Error message. Continously ask user to enter the right number.
  2. Create a Driver class that create 1 vehicle object and 1 car object using Vehicle type reference. Do accelaration for vehicle and changegear for car.

* Please do the pre-programming processes that you need to do ( OOA, OOD,OOP )
* Submit this to my room C9.01 , after the class.

Welcome to SOCIT P2 Exercise Pages


Welcome! Please use this blog to basically try out new Java exercise etc.

To all student of P2 July 2013 , please regularly check this page for new exercise etc.

* Do all the exercises on your own.
* Do not copy others solutions
* The exercise here are meant to gauge your knowledge on p2 so that immediate action can be taken accordingly to ensure that you can maximise your understanding of P2.