Problem regarding the protocol conformance

Assignment Help JAVA Programming
Reference no: EM13963499

Protocol Conformance

We can compare Smalltalk interfaces to classes that use protocols, which are lists of operation names (selectors). When a selector allows parameters, as in at: put: , the selector name includes the colons but not the spaces. More speci?cally, if dict is an updatable collection object, such as a dictionary, then we could send dict a message by writing dict at:‘cross' put:‘angry'. (This makes our dictionary de?nition of "cross" the single word "angry.") The protocol for updatable collections will there- fore contain the seven-character selector name at:put: . Here are some example protocols:

stack : {isEmpty, push:, pop }
queue : {isEmpty, insert:, remove }
priority queue : {isEmpty, insert:, remove }
dequeue : {isEmpty, insert:,insertFront:, remove, removeLast }
simple collection : {isEmpty }

Brie?y, a stack can be sent the message isEmpty, returning true if empty, false oth- erwise; push: requires an argument (the object to be pushed onto the stack), pop removes the top element from the stack and returns it. Queues work similarly, ex- cept they are ?rst-in, ?rst-out instead of ?rst-in, last-out. Priority queues are ?rst-in, minimum-out and dequeues are doubly ended queues with the possibility of adding and removing from either end. The simple collection class just collects methods that are common to all the other classes. We say that the protocol for A conforms to the protocol for B if the set of A selector names contains the set of B selector names.

(a) Draw a diagram of these classes, ordered by protocol conformance. You should end up with a graph that looks like William Cook's drawing shown in Figure 11.6.

(b) Describe brie?y, in words, a way of implementing each class so that you make B asubclass of A only if the protocol for B conforms to the protocol set for A.

(c) For some classes A and B that are unrelated in the graph, describe a strategy for implementing A as a subclass of B in a way that keeps them unrelated.

(d) Describe implementation strategies for two classes A and B (from the preceding set of classes) so that B is a subclass of A, but A conforms to B, not the other way around.

Reference no: EM13963499

Questions Cloud

Relationship between inheritance and subtyping : With this declaration of m in subclass B, any invocation of m on a B object will result in a special error indicating that the method should not be used. (a) What effect does this feature of Smalltalk have on the relationship between inherit..
What is the standard deviation of the annual salary : What is Bob's average annual earnings. In the previous question, what is the standard deviation of the annual salary? What is the probability that John will get 2 tickets during the week (Monday-Friday)?
Perceptions of acl rehabilitation : The purpose of this study is obtaining undiscovered perceptions of strength and conditioning coaches (S&C) and physiotherapists', on what defines a successful return to sport following an anterior cruciate ligament (ACL) injury.
Verify the normalization of the ground state of sho : Examine the normalization condition as applied to the second-state wave function. Can you see a way to apply the results of (a) and (b) to evaluate the integral? [Hint: What happens if you regard the SHO parameter a as a variable and differentiate..
Problem regarding the protocol conformance : We can compare Smalltalk interfaces to classes that use protocols, which are lists of operation names (selectors). When a selector allows parameters, as in at: put: , the selector name includes the colons but not the spaces.
Franchise arrangement between mcdonald''s and its franchisees : The franchise arrangement between McDonald's and its franchisees is summarized
Advantages and disadvantages of optimization : In Smalltalk, each class contains a pointer to the class template. This template stores the names of all the instance variables that belong to objects created by the class.
Specific heat of superheated steam at 150kpa is 2kj/deg : What diameters of inlet and outlet pipes would be required for a flow of 2270kg per hour with a velocity of 15m/s both before and after the reducing valve?
Objects-type case : With object-oriented programming, classes and objects can be used to avoid "type- case" statements. Here is a program in which a form of case statement is used that inspects a user-de?ned type tag to distinguish between different classes of shape ..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Bubble sort on the same machine

final-au13.dvifinal-au13.dvi A) If it takes me 3 seconds to sort 1000 data points using a bubble sort (which is an O(n2) algorithm), roughly how long should it take me to sort 3000 data points using the same bubble sort on the same machine?

  Describe the applications functionality

Create an application for Koch's Cottages, a weekend getaway resort that rents cottages and boats to use on the local lake - Add labels as suitable to describe the application's functionality. Save the file as JCottageFrame.java.

  The continual rise in popularity of php as a solution

Question: With the continual rise in popularity of PHP as a solution to e-commerce applications and the tendency to protect intellectual property, just how open do you think the future will be as far as Web application development is concerned? For t..

  Write a java application that calculates the internet cost

Write a java application that calculates and displays the internet cost and GST (10% Goods & Services Tax) for N customers. N should be declared as a constant and it should be equal to the largest digit of your student ID number.

  Prints out a summary for a list of prescriptions

Create a class that prints out a summary for a list of prescriptions. Using your Prescription class and some if statements you will read in 3 prescriptions and print out an appropriate summary with a list of the prescriptions

  Display the earliest and latest dates that appear in a data

display the earliest and latest dates that appear in a data file, and the number of times that they appear. I have already parsed all of the dates from their original string to their corresponding int values.

  Concepts of polymorphism

This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes

  Hash-join algorithm

In this assignment, you will have a chance to implement the hash-join algorithm for a DBMS. You can use C, C++, or Java to write the program. However, your program should include su- cient comments to make it readable. You need to turn in

  Calculates the area of a triangle

Write a simple Java application which calculates the area of a triangle. Your application should ask the user to enter the base and height values of the triangle.

  How to access to elements of document object model

To limit creation of malicious code, do you believe that access to elements of document object model and some Javascript functionality be limited?

  Write a method shift that takes a stack of integers

Write a method shift that takes a stack of integers and an integer n as parameters and that shifts n values from the bottom of the stack to the top of the stack.

  Create a java application that contains methods to display

Create a Java application that contains methods to display statistics for the numbers in an array. The main method has been written and it's attached. complete the program by writing the following methods.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd