1 / 11

Introduction to Java

Introduction to Java. Week 7 Mobile Phone Library, EasyIn & Command-line IO. Case Study on Mobiles. Mobile phone library New directory/workspace, eg mobile Class definition file MobileNumber.java Demonstration file MobileNumberDemonstration.java

emi-mann
Download Presentation

Introduction to Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Java Week 7 Mobile Phone Library, EasyIn & Command-line IO

  2. Case Study on Mobiles • Mobile phone library • New directory/workspace, eg mobile • Class definition file MobileNumber.java • Demonstration file MobileNumberDemonstration.java • Client demonstration must include main method, to execute

  3. MobileNumber class • MobileNumber String number String name String getNumber() void setNumber( String ) String getName() void setName( String )

  4. Compilation order • Compile class definition file • Compile class demonstration file next (dependency) • Both compile into .class files • Run demonstration program (main) • (Note: child classes are dependent on their parents and have to be compiled first)

  5. MobileWorld & JCreator • To use Workspace facility: • Create a new workspace/ directory • Download the files into the workspace directory • Compile files • If more than one demo program file with main, execute file required only

  6. Demo program • Executable program class must have:public static void main( String[] args) { • To output to command-line:System.out.println( ”Call timed at ..." + getTime() ); • System library part of Java API

  7. Utility class MobileTime • Calls display time in hh:mm (so do alarm calls, reminders etc) • Create utility class • Stores time as int (minutes since midnight) • Convert for display • Note: no checking or validation

  8. MobileTime contents • MobileTime int timeInMinutes int getTime() String getFormattedTime() void setTime(int) • Plus private methods needed to format as hh:mm

  9. EasyIn utility class • In C&K text book • In MobileTime demo:timeInt = EasyIn.getInt(); • Note class call to static method • Also includesgetStringgetDoublepause etc

  10. PhoneCall class • PhoneCall aggregates MobileTime callTime MobileNumber callNumber MobileTime getTime() MobileNumber getNumber • Demo uses EasyIn

  11. Summary • New library of related classes • Mobile classes • Utility classes • Demo programs to test new classes • Command-line IO • Simulations of mobile phone functions

More Related