Preview

Interface Classes

Satisfactory Essays
Open Document
Open Document
594 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Interface Classes
Outline

COMP 102 26/27:2

Designing with Interfaces
#26/#27 COMP 102 #26/#27 2012

• • • • •

Assig 9 Doing without the UI class Multiple types Interface classes Implementing Interface classes.

Peter Andreae
Computer Science Victoria University of Wellington

Reading: Reading
• Textbook • 7.6: 2D arrays • 9.3: Interfaces (note, textbook also discusses inheritance)

Copyright: Peter Andreae, Victoria University of Wellington
© Peter Andreae

ImageProcessor
• Fade
180 255 60 0

COMP 102 26/27:3

Assignment 9: Motel Booker
• • • •
0 1 2 3 4 5 6 7 8

COMP 102 26/27:4

• 2D Array of Bookings (each Booking has name and phone) display, add, delete. load from and save to file find free space
Mon Tue Wed Thu Fri Sat Sun

255 30

© Peter Andreae

© Peter Andreae

Types again
• Only values of the specified type can be put into a place

COMP 102 26/27:9

Object types
• All object values have two types:
• the type they were created as • the Object type

COMP 102 26/27:10

Variables, fields, array elements are all defined with a type What types are there
• primitive types: int, double, boolean, long, float, char, .. note: java will "coerce" some types into other types: double number = 4; • Object types: Every class • Arrays : int[ ], double[ ][ ], Balloon[ ], defines a type • Predefined: String, Color, File, Scanner, … • Programmer defined: CartoonFigure, Balloon, BalloonGame, … • Type of object determined at its creation: • new Balloon(100, 300) ⇒ a Balloon object • new File ("data.txt") ⇒ a File object • new int[100][100] ⇒ an array of arrays of int. • "Hello" ⇒ a String

• You can have a place of type Object:
Object value = new Balloon(100, 100); value = "not any more";

There are limits on what you can do with a place of type Object: value.pop(); value.toUpperCase();
Won't work if value contains a String Won't work if value contains a Balloon

You can only call methods on the value in a variable/field if the

You May Also Find These Documents Helpful

  • Satisfactory Essays

    IT215 INVENTORY PART DVD

    • 302 Words
    • 2 Pages

    Week Six introduces superclasses and subclasses and their relationship to inheritance. These subjects are built upon to introduce the concept of polymorphism. Students learn how to declare, create, initialize, and manipulate arrays.…

    • 302 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Student will learn how to write Java programs to perform simple calculations, they will use Scanner class to obtain input from the console, they will know how to use identifiers to name variables, constants, methods, and classes. The use of constants , Java primitive…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Good Essays

    Array Structure Paper

    • 833 Words
    • 4 Pages

    Once again Berry’s Bug Blasters are requesting an update to the previous program that was designed to help them to better serve their customers. The company has requested a way to display the name and phone number of their clients so that they can keep a record of what clients have called. The best way in the opinion to accomplish this is to build an array into the program. This will allow those in charge of the company record to record who has called and then to display the names of the clients and their number in a chart so that it can be recalled at a later date as needed.…

    • 833 Words
    • 4 Pages
    Good Essays
  • Good Essays

    6. Data hiding, which means that critical data stored inside the object is protected from code outside the object is accomplished in Java by _____.…

    • 1518 Words
    • 7 Pages
    Good Essays
  • Good Essays

    W8 Comp

    • 898 Words
    • 4 Pages

    2) If a variable holds the value "Ferrari," what is its data type? (Points : 5) Numeric Integer Floating point String…

    • 898 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    5. What two things must you normally specify in a variable declaration? You must specify the variable type and identifier.…

    • 748 Words
    • 3 Pages
    Powerful Essays
  • Better Essays

    com 110 class project

    • 5223 Words
    • 21 Pages

    Gone With the Wind, is not only an ultimate favorite among many Americans of the past, present and even to the future generations, but also my favorite movie of all time. Taking place in several places among the South before, during and the ending of the Civil W and shows just a glimpse of life is given and the struggles that were faced at this time; including, but not limited to: love, financial hardships, jealousy, greed, murder and death while hinting at slavery and some racism.…

    • 5223 Words
    • 21 Pages
    Better Essays
  • Good Essays

    Class Ring

    • 636 Words
    • 3 Pages

    Picture a beautiful, young, loving, smart girl with caring parents and one amazing boyfriend. Now picture that becoming all a lie. Picture a seventeen year old falling in love with a psychopath, and having no clue about the situation. Having your perfect world torn apart right in front of you with no control of stopping it. . Ask Natasha Kennedy just how that happened to her. She was in a picture-perfect relationship with Jayven Ray, her boyfriend of eight months. He gave her everything she could dream of, love, gifts, time, and always had the right words to say. She was infatuated with him, the perfect man was in her grasp and she was not letting go. After he knew just how head over heels she was for him, the loving, caring, perfect Jayven turned into her worse nightmare. He became abusive, controlling, and overbearing. She loved him, so of course she let the situation proceed. She was hoping the old Jayven would come back.…

    • 636 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Classconflict

    • 269 Words
    • 1 Page

    In the article "class conflict " by Robert Lapides , presents the American society had made white people racists by the economic classes. The author shows the Malcolm thoughts. Which believed that white people were born racism . But when he met a group of white Muslims, who treated him with respect . Eventually , he changed his mind. And also understood that the society and the economic class had made people racist.…

    • 269 Words
    • 1 Page
    Satisfactory Essays
  • Better Essays

    Helium Weather Balloons

    • 803 Words
    • 4 Pages

    Two basic types of meteorological balloons: the smaller pilot and the larger balloons. The smaller balloons are usually tracked with a theologize; these balloons are not made to carry a payload. The larger balloons are specialized to carry a radiosonde in the air, and these balloons are commonly used by a rawinsonde tracking station. They can also carry other types of payload, such as radar targets.…

    • 803 Words
    • 4 Pages
    Better Essays
  • Good Essays

    Gas Law

    • 548 Words
    • 3 Pages

    Hot air balloons might seem magical to some people because of its ability to float in the sky, but the process that allows them to take flight is actually very uncomplicated. The balloons are prime examples of the implementation of gas laws. The physics are based on the simple principle that warm air rises in cooler air. Hot air has less mass per unit of volume.…

    • 548 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    The responsibility of the project will be the Project Manager and any employees who work under the…

    • 271 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    EDUC CLASS

    • 615 Words
    • 2 Pages

    Success is the accomplishment of one’s goals or endeavors. All throughout my life, success has been the main ambition for everything I do. It is what has given me the determination and power to push through any challenge that stood in my way of achieving what I sought. I, just like everyone else, have my own unique learning, studying, and personality traits which help make who I am as a student today. These inherent traits give me the best possible results for myself as a person to succeed in my entire career as a student.…

    • 615 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    str = "insert into Staff values(" & Text1.Text & ",'" & Text2.Text & "', " & Text3.Text & "," & Text4.Text & ",'" & Text5.Text & "')"…

    • 270 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Many potential users are not sophisticated programmers, and so simple means of access must be available. Means of more sophisticated access must also be available.…

    • 1174 Words
    • 5 Pages
    Powerful Essays