Question

In: Computer Science

Read the following specification and then answer the questions that follow. Specification: A soccer league is...

Read the following specification and then answer the questions that follow. Specification:

A soccer league is made up of at least four soccer teams. Each soccer team is composed of seven(7) to eleven(11) players, and one player captains the team. A team has a name and a record of wins and losses. Players have a number and a position. Soccer teams play games against each other. Each game has a score and a location. Teams are sometimes lead by a coach. A coach has a level of accreditation and a number of years of experience, and can coach multiple teams. Coaches and players are people, and people have names and addresses.

Question: Carry out an initial object oriented design for the above specification.

You must identify and write down. Classes that you think will be required [5 marks]

Their attributes and behaviours [2 marks]

Any inheritance relationships you can identify [3 marks]

Any other relationships (aggregation or otherwise between the classes) [2 marks]

Solutions

Expert Solution

Object–Oriented Design (OOD): involves implementation of the conceptual model produced during object-oriented analysis. In OOD, concepts in the analysis model, which are technology−independent, are mapped onto implementing classes, constraints are identified and interfaces are designed, resulting in a model for the solution domain, i.e., a detailed description of how the system is to be built on concrete technologies.

The implementation details generally include −

  • Restructuring the class data (if necessary),
  • Implementation of methods, i.e., internal data structures and algorithms,
  • Implementation of control, and
  • Implementation of associations.

Object:

An object is a real-world element in an object–oriented environment that may have a physical or a conceptual existence. Each object has −

  • Identity that distinguishes it from other objects in the system.

  • State that determines the characteristic properties of an object as well as the values of the properties that the object holds.

  • Behavior that represents externally visible activities performed by an object in terms of changes in its state.

  • Object-oriented programming (OOP) languages are designed to overcome these problems.

  • The basic unit of OOP is a class, which encapsulates both the static attributes and dynamic behaviors within a "box", and specifies the public interface for using these boxes. Since the class is well-encapsulated (compared with the function), it is easier to reuse these classes. In other words, OOP combines the data structures and algorithms of a software entity inside the same box.

Objects can be modelled according to the needs of the application. An object may have a physical existence, like a customer, a car, etc.; or an intangible conceptual existence, like a project, a process, etc.

Class :

A class represents a collection of objects having same characteristic properties that exhibit common behavior. It gives the blueprint or description of the objects that can be created from it. Creation of an object as a member of a class is called instantiation. Thus, object is an instance of a class.

The constituents of a class are −

  • A set of attributes for the objects that are to be instantiated from the class. Generally, different objects of a class have some difference in the values of the attributes. Attributes are often referred as class data.

  • A set of operations that portray the behavior of the objects of the class. Operations are also referred as functions or methods.

As an example, suppose you wish to write a computer soccer games . It is quite difficult to model the game in procedural-oriented languages. But using OOP languages, you can easily model the program accordingly to the "real things" appear in the soccer games.

  • Player: attributes include name, number, location in the field, and etc; operations include run, jump, kick-the-ball, and etc.
  • Ball:
  • Reference:
  • Field:
  • Audience:
  • Weather:

Every player is a different person, but they all have something in common: they can perform the same actions, such as running or passing, and they share certain features, like a number and a position. The same thing could be said for coaches and the rest of the staff. Each one of them will have different combinations, but they all follow the same model.

A class is a model, a blueprint, a template that describe some features. More precisely, a class represents data, usually with variables called fields, and behaviors, represented by functions, usually called methods. For example, a class Player could have a field called Role to represent its role, or position, on the actual field of the game, a Name, to represent his name. As behavior it could have a method Pass(Player), that would make him pass the ball to some other player.

ex:

class player
{
Text name
Text address
pass (player  Teammate)
{         
//body of method
}
}

A class can be visualized as a three-compartment box, as illustrated:

  1. Classname (or identifier): identifies the class.
  2. Data Members or Variables (or attributes, states, fields): contains the static attributes of the class.
  3. Member Functions (or methods, behaviors, operations): contains the dynamic operations of the class.

In other words, a class encapsulates the static attributes (data) and dynamic behaviors (operations that operate on the data) in a box.

Class Members: The data members and member functions are collectively called class members.

Object:

If a class is a model what are the actual players? They are called objects or instances of the class. In the previous example, the argument teamMate was an object. To create an object from a class you instantiate, or create, an object.

For example, the object of the class Player smith has the Name  and the address  

here player is class and name and address are objects

coach is class and name,age,address are objects.

ex:class SoccerPlayer {   // classname
private:
   int number;         // Data members (variables)
   string name;
   int x, y;
public:   
   void run();         // Member functions
   void kickBall();
}

Encapsulation

Encapsulation is the process of binding both attributes and methods together within a class. Through encapsulation, the internal details of a class can be hidden from outside. It permits the elements of the class to be accessed from outside only through the interface provided by the class.

For instance, to simulate the ability to run, the class Player has a method called Run(), but it also has a field called Legs. This field represents the condition of the legs of the player: how tired they are and their health, that is to say, whether they are injured. The outside world does not need to know that the Player has Legs and how they operate.

Data Hiding:

Typically, a class is designed such that its data (attributes) can be accessed only by its class methods and insulated from direct outside access. This process of insulating an object’s data is called data hiding or information hiding.

Abstraction

Abstraction refers to hiding the details of the implementation from the outside the class.

As an example, the object Man of the class Coach call the method Run() of John, an object of the class Player. It does not know what John must do to actually run. It just needs to know that an object of the class Player has the method Run().

Inheritance :

Inheritance is the mechanism that permits new classes to be created out of existing classes by extending and refining its capabilities. The existing classes are called the base classes/parent classes/super-classes, and the new classes are called the derived classes/child classes/subclasses

As an example, you notice that the Player, Coach and Staff classes have a name and a salary, so you create a parent class called Person and you made them inherit from it. Notice that you just keep creating only an object of the class Player, Coach, etc. you don’t need to explicitly create an object of the class Person.

types of inheritance

  • Single Inheritance − A subclass derives from a single super-class
  • Multiple Inheritance − A subclass derives from more than one super-classes.

  • Multilevel Inheritance − A subclass derives from a super-class which in turn is derived from another class and so on.

Interface :

Interface, also known as protocol, is an alternative to inheritance for two unrelated classes to communicate with each other. An interface defines methods and (often, but not always) values. Every class that implements the interface must provide a concrete method for each method of the interface.

For example, you want to simulate ejection, or dismissal. Since only players and coaches can be ejected from the field, you cannot make it a method of the parent class that represents people. So you create an interface Ejectablewith a method Ejection() and make Player and Coach implement it.

Association:

An association simply describes any kind of working relation. The two object are instances of completely unrelated classes, and none of the objects controls the lifecycle of the other one. They just collaborate to accomplish their own goals.

Imagine that you want to add the effect of the audience on the players; in real life the audience is made of people, but in our simulation, they are not children of the class Person. You simply want to make that if the object HomePeople of the class Audience is cheering then John is playing better. So HomePeople can affect the behavior of John, but neither HomePeople nor John can control the lifecycle of the other.

Aggregation :

An aggregation describes a relationship in which one object belongs to another object, but they are still potentially independent. The first object does not control the lifecycle of the second.

In a team sport, all objects of class Player belong to an object of Team, but they don’t die just because they are fired. They could be unemployed for a while or change Team.

This kind of relationship is usually described as has-a (or is-part-of), or on the inverse belongs-to. In our example the object Winners of Team has-a John of Player, or on the inverse John belongs-to Winners.


Related Solutions

Read the following and answer the related questions that follow it. Auric plc is a mining...
Read the following and answer the related questions that follow it. Auric plc is a mining company, whose main business consists of open cast mining. It has Articles of Association that are in the form of model Articles. The board of directors includes Penny, Howard and Emily. At a recent board meeting, the directors considered an offer from Trek Mines plc to sell land adjoining one of Auric plc’s mining sites for £550,000. The board of Auric plc decided that...
Read the following and answer the related questions that follow it. Auric plc is a mining...
Read the following and answer the related questions that follow it. Auric plc is a mining company, whose main business consists of open cast mining. It has Articles of Association that are in the form of model Articles. The board of directors includes Penny, Howard and Emily. At a recent board meeting, the directors considered an offer from Trek Mines plc to sell land adjoining one of Auric plc’s mining sites for £550,000. The board of Auric plc decided that...
Read the following scenario and answer the questions that follow in the discussion board area of...
Read the following scenario and answer the questions that follow in the discussion board area of class. Provide a thoughtful and informative response to the questions; you should be able to support your recommendations. Be sure to support your ideas with evidence gathered from reading the text or other outside sources. Be sure to give credit to the sources where you find evidence. Use an attribution like "According to the text," or "According to Computer Weekly website" in your response....
Read the following case study, then answer the questions that follow. Akot is an aged care...
Read the following case study, then answer the questions that follow. Akot is an aged care coordinator. He conducts an assessment of Mrs. Brown using a falls assessment tool. Mrs. Brown tells him she is extremely confident she will not fall when carrying out all activities of daily living, circling 10 in response to all of the questions on the scale. Later, Akot observes Mrs. Brown and notes she moves quite slowly and maintains contact with the handrail while walking...
A. Please read the following situation statement and answer the questions that follow: While traveling on...
A. Please read the following situation statement and answer the questions that follow: While traveling on business with a co-worker, you spend quite a few evenings having dinner and cocktails with your co-worker’s extended family that lives in town. After each of these meals your co-worker charges the entire meal to his corporate credit card, which he then submits as a business expense as part of his travel expense report. As these meals were not overly extravagant, the total value...
Read the following case study, then answer the questions that follow. Gayle is an aged care...
Read the following case study, then answer the questions that follow. Gayle is an aged care support worker. She is working with Leila, an older person, who needs to exercise to build muscle mass and bone density to decrease the likelihood of falling and associated health risks as a result of falls. The district nurse and Leila support this strategy. Leila’s family is also involved in her case, and they disagree and are openly hostile towards Gayle and others in...
Read the following case and answer the questions that follow: GeoPetro is independent oil and natural...
Read the following case and answer the questions that follow: GeoPetro is independent oil and natural gas company with headquarters in San Francisco, California. It recently received an audit opinion that expressed a going concern paragraph. The following is an excerpt from GeoPetro’s 2012 report: The accompanying consolidated financial statements have been prepared assuming that the Company will continue as a going concern. As discussed in Note 2 to the consolidated financial statements, the Company has incurred recurring net losses...
Read the following case study and answer the questions that follow. Submit your answers to this...
Read the following case study and answer the questions that follow. Submit your answers to this Dropbox. The Case of the Coughing Housewife Jessica, a fifty-nine year old mother of four, moved from a ranch in Colorado to Los Angeles, after the death of her husband, to be closer to her oldest son and his family. She has been in Los Angeles for 18 months and has noticed that she is experiencing shortness of breath which has worsened over the...
Read the following statement carefully and then answer the questions that follow. The equilibrium constant (Kp)...
Read the following statement carefully and then answer the questions that follow. The equilibrium constant (Kp) for the reaction of solid carbon with carbon dioxide producing carbon monoxide at 850 ºC, has a value of 0.70: A. Write the reaction that takes place and the corresponding half-reactions. B. Calculate the partial pressure of the equilibrium if you initially have 1 mole of CO2, in a 30 L container and at a temperature of 850 ºC, in addition to solid carbon....
Read the following case study and answer the questions that follow. Professional and Ethical Conduct in...
Read the following case study and answer the questions that follow. Professional and Ethical Conduct in the Public Sector One of the basic values and principles governing public administration enshrined in the Constitution of the Republic of South Africa, 1996 (Chapter 10) is that “a high standard of professional ethics must be promoted and maintained. Ethics is a process by which we clarify right and wrong and act on what we take to be right, that is, a set or...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT