1 / 19

CSE 1341 - Honors Principles of Computer Science I

CSE 1341 - Honors Principles of Computer Science I. Spring 2008 Mark Fontenot mfonten@engr.smu.edu. Note Set 22. Note Set 21 Overview. Creating packages in Java Wrap up What else can you do now?. Packages. We’ve done a good deal of import java.util .*; import javax.swing .*;

quinta
Télécharger la présentation

CSE 1341 - Honors Principles of Computer Science I

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. CSE 1341 - HonorsPrinciples of Computer Science I Spring 2008 Mark Fontenot mfonten@engr.smu.edu Note Set 22

  2. Note Set 21 Overview • Creating packages in Java • Wrap up • What else can you do now?

  3. Packages • We’ve done a good deal of • import java.util.*; • import javax.swing.*; • What does that mean really? • Every class belongs to a package • Packages • contain groups of related classes • help organize code base of complex applications • facilitate software reuse • help prevent class-name conflicts

  4. Steps for Declaring Reusable Class Declare a class public. If class not public, can only be used by other classes in same package. Choose unique name and add package declaration to source file package edu.smu.cse.mef; Compile class so that directory structure is createdNetbeans does this automatically for source and compiled version Use code elsewhere

  5. Example Student.java package edu.smu.cse.mef; public class Student { private String name; private String id; private int test1; private int test2; public Student(String n, String i, int t1, int t2) { name = n; id = i; test1 = t1; test2 = t2; } }

  6. Directory Structure

  7. Importing the class that was created

  8. Import Types • Single-type-import declaration • specifies exactly one class to import • import java.util.Scanner; • Type-Import-On-Demand Declaration • Allows all classes from a package to be accessed and used • import java.util.*;

  9. What else is there? • What else is there beyond Java? • Some say there are over 2000 (!!!!) programming languages in existence. • Why learn to program? • computers are dumb • they need to be told exactly what to do – step by step • Programming is a tool • Few people program just to earn “cool” points • Use a computer to solve a particular problem – must tell it what to do

  10. Why? Computers are nearly ubiquitous Think of a scenario where you can exists for 7 days with out interaction of a computer OR without interaction with anything that was influenced or designed by a computer!!!! Computers/processors are all over the place….They all need software to run so that they perform useful work

  11. What else can Java do? • Create apps for portable devices/embedded devices • J2ME – Java 2 Micro Edition • examples: mobile phones, PDAs, TV set-top boxes, printers • Create web-based services and next-gen web applications • J2EE – Java 2 Enterprise Edition • Examples: E-commerce websites • Access web-services and APIs • Google API • YouTube API • Facebook API

  12. What is possible? Finding Cures for Diseases? Enabling the disabled? Speeding up the Internet? Developing the next great web-app? Solving world hunger?

  13. Examples • Bioinformatics/Computational Biology • Using computer science and algorithms to solve biologically relevant problems • Data Mining/Informatics • Effectively managing data and gleaning information from raw data • Computer Aided Design (not drawing houses) • Using computers to design computers • Optimization Issues (OR and CS) • UPS reduces number of left turns to save fuel.

  14. Other Languages – C# C# Code using System; class A{ public static void Main(String[] args){ Console.WriteLine("Hello World"); } } Java Code class B{ public static void main(String[] args){ System.out.println("Hello World"); } } C# Code String csString = "Apple Jack"; csString.ToLower(); Java Code String jString = "Grapes"; jString.toLowerCase();

  15. Other Languages – C++ int main () { string s; s = “Hello”; stack<char> stk; for (inti = 0; i < s.size(); i++) stk.push(s[i]); while (!s.isEmpty()){ cout << stk.top(); stk.pop(); } return 0; }

More Related