Skip to content

OOP-ADF/Task_3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task_3 - 2017

Exercise on Class Relationship

This exercise is intended to allow students to practice basic Class Relationship
Aggregation and Composition

There are 2 Exercises that you have to complete individually
write down your identity (Name, Student ID, Class) on the top of each file


Exercise 1

Task 3 - Exercise 1 - 2017

Write Java Program as described in Class Diagram below

![Class Diagram Exercise 1] (/exercise1.JPG)

  • Class Application.java

  • Constructor initialize application name and size (MB)

  • Method toString() : String returns String that contains application name and application size
    example : "Application name: App_1, with size: 3MB"

  • Class AppStore.java

  • method createNewApp( appName, appSize ) instantiate new Application object and insert it in array appList

  • method getApp( id ) : Application returns Application object from array appList with array index = id

  • Method toString() : String returns String that contains the number of Application available
    example : "There are 5 applications ready to install"

  • Class SmartPhone.java

  • method addApplication( appStore , appId ) get an Application object from array appList of an appStore with array index = appId
    an Application can be installed if Application size < remaining memory size

  • method getRemainingSize() : int returns the remaining memory size of the smart phone

  • Method toString() : String returns String that contains the smart phone total memory size, number of application installed, and remaining memory size
    example : "memory size 100MB, 5 application installed, remaining memory size: 60MB"

Write a Driver.java class (Main class) to test these scenarios
(Scenario Testing)

  • instantiate 1 AppStore object aps
    example : AppStore aps = new AppStore();
  • create 4 new Applications within the App Store aps, with app name = app1, app2, app3, and app4; and app size 100, 200, 300, and 400
    example : aps.createNewApp( "app1" , 100 );
  • display the status of App Store aps
    example : System.out.println( aps );
  • display the status of one of application available on App Store aps
    example : System.out.println( aps.getApp( 2 ) );
  • instantiate 1 SmartPhone object sm, set the memory size 300
    example :
    SmartPhone sm = new SmartPhone();
    sm.setMemory(300);
  • display the status of SmartPhone sm
    example : System.out.println( sm );
  • install applications (in sequence) app1, app3, and app2 in SmartPhone sm
    example : sm.addApplication( aps, app1 );
  • display the status of SmartPhone sm after each installation

Try another scenario case on your own


Exercise 2

Task 3 - Exercise 2 - 2017

Write Java Program as described in Class Diagram below

![Class Diagram Exercise 2] (/exercise2.JPG)

  • Class Member.java

  • Create 2 Constructors : initialize name, and initialize name and specialization

  • Method toString() : String returns String that contains member name, specialization, and number of project worked
    example : "Member Alex specialized in Java Programming and already worked on 5 projec(s)"

  • Class Project.java

  • Constructor initialize project name, instantiate array member with size of [5],
    and set release status = false

  • method addMember( m : Member ) add an object Member m into array team member
    increment integer nTeam+1

  • method releaseApp() set release status = true

  • Method toString() : String returns String that contains Project name, number of team member, and release status
    example : "Project Exodus status is in progress with team member of 4"

  • Class StartUp.java

  • method addMember( m : Member ) add an object Member m into array member
    increment integer nMember+1

  • method getMember( id : int ) : Member returns Member object from array member with array index = id

  • method createNewProject( projectName : String ) instantiate new Project object and insert it in array projectList
    increment integer nProject+1

  • method getProject( id : int ) : Project returns Project object from array projectList with array index = id

  • method releaseProject( p : Project ) set release status of object Project p by invoking method releaseApp()

  • method getNumReleasedProject() : int returns number of project with status is released

Write a Driver.java class (Main class) to test these scenarios
(Scenario Testing)

  • instantiate 1 StartUp object stp
    example : StartUp stp = new StartUp();
  • instantiate 5 new Member objects with name = Alex, Beni, Cakra, Deni, and Eric; and add them to StartUp stp
    example :
    Member m = new Member("Alex");
    stp.addMember( m );
  • create 2 Project object within the Start Up stp, with project name = project1 and project2
    example : stp.createNewProject( "project1" );
  • set project member as below
  • add Alex, Beni, and Deni into Project1
  • add Beni, Cakra, Deni, and Eric into Project2 example :
    Project p = stp.getProject( 0 );
    Member m = stp.getMember( 0 );
    stp.setProjectMember( p , m );
  • set release one of the project
    example : stp.releaseProject( stp.getProject( 1 ) );
  • display the status of every member in Start Up stp
    example : System.out.println( stp.getMember( 0 ) );
  • display the status of every project in Start Up stp
    example : System.out.println( stp.getProject( 0 ) );
  • display the number of released project in Start Up stp

Try another scenario case on your own

About

Exercise on Class Relationship

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages