Questions
What is an Object? Coad and Yourdon - A person or thing through which action, thought, or...

What is an Object?


Coad and Yourdon - A person or thing through which action, thought, or feeling is directed. Anything visible or tangible; a material product or substance.


James Martins – From a very early age, we form concepts. Each concept is a particular idea or understanding we have about our world. These concepts allow us to make sense of and reason about the things in our world. These things in our world. These things to which our concepts apply are called objects.


Grady Booch – A tangible and/or visible thing; something that may be apprehended intellectually; something toward which thought or action is directed. An individual, identifiable item, unit, or entity, either real or abstract, with a well-defined role in the problem domain. Anything with a crisply defined boundary.


Coleman - An object is a thing that can be distinctly identified. At the appropriate level of abstraction almost anything can be considered to be an object. Thus a specific person, organization, machine, or event can be regarded as an object.


OBJECT THINK


The object thinks approaches help us believe that an object in a computer system is like us. Hence to find out about the object, we let it talk about itself

An example is a button on a screen

I am a button on the screen

I know what window I am attached to


I know my position in the window


I know my height and width


I know background color


I know what the label that appears on me says


I know what to do when pushed


Using Object Think in terms of the environment the object is in.

An example is a dog

I am actually a dog

I know people call me Rover


I know people with certain voices and smells regularly feed me.


I know how to eat, sleep, roll over, bark and chase cars


  An example of a dog in the context of a veterinarian’s administrative work


I am a dog object in the work context of a veterinarian

I know my license number, name, breed, birth date and weight


I know the owner I am associated with.


I know the check up results I am associated with


I know my next appointment date and time


I know if my patients’ status is “all paid up” or “payment overdue”


TASK ONE


Identify and name the following objects and identify the work context based on the object think description provided.


             I am a ___________ in the work context of a ____________.


                        I know my title, author, and call number


                        I know how to be checked out.


                        I know how to be returned.


             I am a __________ in the work context of a ____________.


                        I know my title, author, publisher, price and ISBN number


                        I know how to be put on order


                        I know how to be stocked


                        I know how to be sold


                        I know how to be returned


TASK TWO


Use the object think approach to write description for the following


I am actually a car


I am a car object in the work context of a repair shop


I am a car object in the work context of a car collector.


In: Computer Science

Lab 3 Java Classes and Memory Management Multi-file Project In this lab you will gain experience...

Lab 3 Java Classes and Memory Management

Multi-file Project

  1. In this lab you will gain experience using classes and arrays of classes. Use the following as the beginning of a student abstract data type.

public class Student

{

private String fName ;

private String lName ;

private double[] grades;

}

This class should be in the package com.csc241. Write a program that prompts a user for a total number of students and dynamically allocates memory for just that number of Student objects in a Student[]. Then continuously re-prompt the user to enter, on a studentbystudent basis,

  1. a student’s first and last name to be used in populating the class data members fName and lName with appropriate set methods. Use local String variables to hold the values entered by the user.
  2. the number of grades for the student to be stored in nGrds, a local variable of the main program.

Next,

  1. dynamically allocate memory for the grades and assign the resulting reference to a local double[]. Prompt the user for the nGrds values and after acquiring them all, assign the local grades array to the Student instance in the array using an appropriate set method.
  2. re-use the MaxMin class you wrote in a previous lab, but also put it in the package com.csc241. Similarly, the GradeCalculator class that you created in the last assignment needs to be in the com.csc241 package. You will be using the avg and maxMin static methods that accept the grades[] in order to compute individual student statistics.
  3. In order for you to calculate ensemble statistics, that is statistics for the entire class, the GradeCalculator class will need methods avg and maxMin that accept as an argument the Student[] that you dynamically allocated. These methods must loop through the individual grades[] of each Student array element in order to compute the total class average, max and min values.
  4. display the results to the user, both on a per student and ensemble basis. Your output should appear as shown below. Please make note of and reproduce all the decimal formatting and other characteristics of the sample output.

As always, keep in mind all of the general rules of good program construction.

How many students are in your class - 3

Enter the first name of student #1 - Joe

Enter Mike’s last name - Shmo

How many grades will you be entering for Joe Shmo? – 5

Plz enter the grades for Joe Shmo

100

97

87

87

92

Grade Statistics for Joe Shmo (average=92.6 ; max/min=100/87)

Enter the first name of student #2 - Jack

Enter Jack’s last name - Schwartz

How many grades will you be entering for Jack Schwartz? – 3

Plz enter the grades for Jack Schwartz

100

90

0

Grade Statistics for Jack Schwartz (average=63.3 ; max/min=100/0)

Enter the first name of student #3 - Joan

Enter Joan’s last name - Jameson

How many grades will you be entering for Joan Jameson? – 4

Plz enter the grades for Joan Jameson

98

95

93

94

Grade Statistics for Joan Jameson (average=95.0 ; max/min=98/93)

Ensemble Statistics - Average=86.1 ; Max/Min=100/0)

Do you wish to continue (Y/N) - n

In: Computer Science

Implement the minimum priority queue UnsortedMPQ (using vector) that is a child class of the provided...

Implement the minimum priority queue UnsortedMPQ (using vector) that is a child class of the provided MPQ class. The functions from MPQ that are virtual function (remove min(), is empty(), min(), and insert()) must be implemented in the child classes. The functions remove min() and min() should throw an exception if the minimum priority queue is empty.

For the UnsortedMPQ class, you will use a vector to implement the minimum priority queue functions. The insert() function should be O(1) and the remove min() function should be O(n).

Below I will attach the parent class (MPQ.h), child class (unsortedMPQ.h - needs implementation), and unsortedMPQ-main.cpp - for testing and does not need to be implemented.

Please Code in C++.

MPQ.h

#ifndef MPQ_H
#define MPQ_H

//Abstract Minimum Priority Queue Class
template
class MPQ{
public:
virtual T remove_min() = 0;
virtual T min() = 0;
virtual bool is_empty() = 0;
virtual void insert(const T& data) = 0;
};
#endif

unsortedMPQ.h

#ifndef UNSORTEDMPQ_H
#define UNSORTEDMPQ_H

#include
#include
#include "MPQ.h"

/*
* Minimum Priority Queue based on a vector
*/
template
class UnsortedMPQ: MPQ {

};

#endif

unsortedMPQ-main.cpp (for testing)

#include "UnsortedMPQ.h"
#include

using namespace std;

int main() {
{
UnsortedMPQ mpq;
cout << "Inserting 1 - 5" << endl;
mpq.insert(1);
mpq.insert(2);
mpq.insert(3);
mpq.insert(4);
mpq.insert(5);
cout << "Remove min five times" << endl;
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << endl << endl;
}
{
UnsortedMPQ mpq;
cout << "Inserting 5 - 1" << endl;
mpq.insert(5);
mpq.insert(4);
mpq.insert(3);
mpq.insert(2);
mpq.insert(1);
cout << "Remove min five times" << endl;
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << endl << endl;
}
{
UnsortedMPQ mpq;
cout << "Inserting mixed order 1-5" << endl;
mpq.insert(5);
mpq.insert(2);
mpq.insert(4);
mpq.insert(3);
mpq.insert(1);
cout << "Remove min five times" << endl;
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << endl << endl;
}
{
UnsortedMPQ mpq;
cout << "Testing exception" << endl;
try {
mpq.remove_min();
}
catch (exception& e) {
cout << e.what() << endl;
}
cout << endl;
}
{
UnsortedMPQ mpq;
cout << "Inserting mixed order 1-5" << endl;
mpq.insert(5);
mpq.insert(2);
mpq.insert(4);
mpq.insert(3);
mpq.insert(1);
cout << "Remove min five times" << endl;
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << endl;
cout << "Inserting mixed order 11-15" << endl;
mpq.insert(15);
mpq.insert(12);
mpq.insert(14);
mpq.insert(13);
mpq.insert(11);
cout << "Remove min five times" << endl;
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << ", ";
cout << mpq.remove_min() << endl;
cout << "Testing exception" << endl;
try {
mpq.remove_min();
}
catch (exception& e) {
cout << e.what() << endl;
}
}
return 0;
}

In: Computer Science

Define the class HotelRoom. The class has the following private data members: the room number (an...

Define the class HotelRoom. The class has the following private data members: the room number (an integer) and daily rate (a double). Include a default constructor as well as a constructor with two parameters to initialize the room number and the room’s daily rate. The class should have get/set functions for all its private data members [20pts]. The constructors and the get/set functions must throw an invalid_argument exception if either one of the parameter values are negative. The exception handler should display the message “Negative Parameter” [20pts]. Include a toString() function that nicely formats and returns a string that displays the information about the hotel room [10pts].

  1. Write a main function to test the class HotelRoom, create a HotelRoom object. Try to set the room rate to an invalid value to generate an exception. Invoke the toSting() function to display the HotelRoom object. [20pts]
  2. Derive the classes GuestRoom form the base class HotelRoom. The GuestRoom has private data fields and public functions:
    1. The private data field capacity (an Integer) that represents the maximum number of guests that can occupy the room. [5pts]
    2. The private data member status (an integer), which represents the number of guests in the room (0 if unoccupied). [5pts]
    3. An integer data field days that represents the number of days the guests occupies the room. [5pts]
    4. Add constructors and get/set functions to the GuestRoom class. The set function for the status data member must throw an out_of_range exception if it tries to set status to value greater than the capacity. [30pts]
    5. The function calculateBill() that returns the amount of guest’s bill. [10pts]
    6. Redefine the function toString() that formats and returns a string containing all pertinent information about the GuestRoom. [15pts]
  3. Derive the classes MeetingRoom form the base class HotelRoom. The class has the following private data filed sand public functions:
    1. A private data field seats, which represents the number of seats in the room. [5pts]
    2. An integer data field status (1 if the room is booked and 0 otherwise). [5pts]
    3. Add constructors and get/set functions to the GuestRoom class. [10pts]
    4. Redefine the function toSting() to format and return a string containing all pertinent information about the MeetingRoom. [20pts]
    5. The function CalculateBill(), which returns the amount of the bill for renting the room for one day. The function calculates the bill as follows: the number of seats multiplied by 10.00, plus 500.00. [20pts]
  4. Write a main function to test the classes GuestRoom and MeetingRoom. Invoke the calculateBills and toStirng() in each of the objects. [40pts]]
  5. Make changes to the HotelRoom class to implement polymorphism. Add a virtual function calculateBill() that returns 0.00 and make the toString() function in the HotelRoom class a virtual function. Write the function displayHotelRoom() that receive a base class type reference as a parameter, then invokes the functions calculateBill() and toString(). The function must return void. [50pts]
  6. From the main function invoke the function displayHotelRoom() three separate times and each time send a HotelRoom, a GuestRoom, and a MeetingRoom type objects. [20pts]

  7. Repeat parts e and f but make appropriate changes in such a way that HotelRoom is turned into an abstract base class. [50pts]

In: Computer Science

Requirements:   You are to write a class called Point – this will represent a geometric point...

Requirements:   You are to write a class called Point – this will represent a geometric point in a Cartesian plane (but x and y should be ints).   Point should have the following:

Data:  

  • that hold the x-value and the y-value. They should be ints and must be private.

Constructors:

  • A default constructor that will set the values to (2,-7)
  • A parameterized constructor that will receive 2 ints (x then y) and set the data to what is received.
  • A copy constructor that will receive a Point. If it receives null, then it should

throw new IllegalArgumentException(<”your meaningful String here”>);

If it is OK, the it should initialize the data (of the new instance being created) to be the same as the Point that was received.

Methods:

  • The methods to be implemented are shown in the PointInterface.java. You can look at this file to see the requirements for the methods.
  • Your Point class should be defined like this:

public class Point implements PointInterface

When your Point.java compiles, Java will expect all methods in the interface to be implemented and will give a compiler error if they are missing. The compiler error will read “class Point is not abstract and does not implement method ”.

You can actually copy the PointInterface methods definitions into your Point class so it will have the comments and the method headers.   If you do this, be sure to take out the ; in the method headers or you will get a “missing method body” syntax error when compiling…

  • But a toString() method and a .equals(Object obj) method are automatically inherited from the Object class. So if you do not implement them, Java will find and use the inherited ones – and will not give a compiler error (but the inherited ones will give the wrong results). The Point class should have its own .toString and .equals methods.
  • ==============================================================================
  • This is the interface (called PointInterface.Java) for a Point class (which will represent a 2-dimensional Point)
  • public interface PointInterface

    {

    // toString

    // returns a String representing this instance in the form (x,y)

    (WITHOUT a space after the ,)

    public String toString();

    // distanceTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns the distance from this Point to the Point that was

    received

    // NOTE: there is a static method in the Math class called hypot

    can be useful for this method

    public double distanceTo(Point otherPoint);

    //equals - returns true if it is equal to what is received (as an Object)

    public boolean equals(Object obj);

    // inQuadrant

    // returns true if this Point is in the quadrant specified

    // throws a new IllegalArgumentException if the quadrant is

    out of range (not 1-4)

    public boolean inQuadrant(int quadrant);

    // translate

    // changes this Point's x and y value by the what is received (thus

    "translating" it)

    // returns nothing

    public void translate(int xMove, int yMove);

    // onXAxis

    // returns true if this Point is on the x-axis

    public boolean onXAxis();

    // onYAxis

    // returns true if this Point is to the on the y-axis

    public boolean onYAxis();

    //=============================================

    // The method definitions below are commented out and

    // do NOT have to be implemented

    // //===========================================

    // halfwayTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns a new Point which is halfway to the Point that is

    received

    //public Point halfwayTo(Point another);

    // slopeTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns the slope between this Point and the one that is

    received.

    // since the slope is (changeInY/changeInX), then first check to see if

    changeInX is 0

    // if so, then return Double.POSITIVE_INFINITY; (since the

    denominator is 0)

    //public double slopeTo(Point anotherPoint)

    }

In: Computer Science

Requirements:   You are to write a class called Point – this will represent a geometric point...

Requirements:   You are to write a class called Point – this will represent a geometric point in a Cartesian plane (but x and y should be ints).   Point should have the following:

Data:  

  • that hold the x-value and the y-value. They should be ints and must be private.

Constructors:

  • A default constructor that will set the values to (2,-7)

  • A parameterized constructor that will receive 2 ints (x then y) and set the data to what is received.
  • A copy constructor that will receive a Point. If it receives null, then it should

throw new IllegalArgumentException(<”your meaningful String here”>);

If it is OK, the it should initialize the data (of the new instance being created) to be the same as the Point that was received.

Methods:

  • The methods to be implemented are shown in the PointInterface.java. You can look at this file to see the requirements for the methods.

  • Your Point class should be defined like this:

public class Point implements PointInterface

When your Point.java compiles, Java will expect all methods in the interface to be implemented and will give a compiler error if they are missing. The compiler error will read “class Point is not abstract and does not implement method ”.

You can actually copy the PointInterface methods definitions into your Point class so it will have the comments and the method headers.   If you do this, be sure to take out the ; in the method headers or you will get a “missing method body” syntax error when compiling…

  • But a toString() method and a .equals(Object obj) method are automatically inherited from the Object class. So if you do not implement them, Java will find and use the inherited ones – and will not give a compiler error (but the inherited ones will give the wrong results). The Point class should have its own .toString and .equals methods.
  • ==============================================================================
  • This is the interface (called PointInterface.Java) for a Point class (which will represent a 2-dimensional Point)
  • public interface PointInterface

    {

    // toString

    // returns a String representing this instance in the form (x,y)

    (WITHOUT a space after the ,)

    public String toString();

    // distanceTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns the distance from this Point to the Point that was

    received

    // NOTE: there is a static method in the Math class called hypot

    can be useful for this method

    public double distanceTo(Point otherPoint);

    //equals - returns true if it is equal to what is received (as an Object)

    public boolean equals(Object obj);

    // inQuadrant

    // returns true if this Point is in the quadrant specified

    // throws a new IllegalArgumentException if the quadrant is

    out of range (not 1-4)

    public boolean inQuadrant(int quadrant);

    // translate

    // changes this Point's x and y value by the what is received (thus

    "translating" it)

    // returns nothing

    public void translate(int xMove, int yMove);

    // onXAxis

    // returns true if this Point is on the x-axis

    public boolean onXAxis();

    // onYAxis

    // returns true if this Point is to the on the y-axis

    public boolean onYAxis();

    //=============================================

    // The method definitions below are commented out and

    // do NOT have to be implemented

    // //===========================================

    // halfwayTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns a new Point which is halfway to the Point that is

    received

    //public Point halfwayTo(Point another);

    // slopeTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns the slope between this Point and the one that is

    received.

    // since the slope is (changeInY/changeInX), then first check to see if

    changeInX is 0

    // if so, then return Double.POSITIVE_INFINITY; (since the

    denominator is 0)

    //public double slopeTo(Point anotherPoint)

    }

In: Computer Science

The cash flows for three independent projects are found​ below:   Year 0 ​ (Initial investment) ​$(70,000​)...

The cash flows for three independent projects are found​ below:  

Year 0 ​ (Initial investment)

​$(70,000​)

​$(110,000​)

​$(420,000​)

Year 1

​$11,000

​$28,000

​$220,000

Year 2

17,000

28,000

220,000

Year 3

21,000

28,000

220,000

Year 4

26,000

28,000

Year 5

33,000

28,000

.

a. Calculate the IRR for each of the projects.

b. If the discount rate for all three projects is 13 percent​, which project or projects would you want to​ undertake?

c. What is the net present value of each of the projects where the appropriate discount rate is 13 percent​?

In: Finance

Managers of CVS Pharmacy are considering a new project. This project would be a new store...

Managers of CVS Pharmacy are considering a new project. This project would be a new store in Odessa, Texas. They estimate the following expected net cash flows if the project is adopted. Year 0: ($1,250,000) Year 1: $200,000 Year 2: $500,000 Year 3: $400,000 Year 4: $300,000 Year 5: $200,000 Suppose that the appropriate discount rate for this project is 7.7%, compounded annually. Calculate the net present value for this proposed project. Do not round at intermediate steps in your calculation. Round your answer to the nearest dollar. If the NPV is negative, include a minus sign. Do not type the $ symbol.

In: Finance

Assume you are to receive a 10-year annuity with annual payments of $800. The first payment...

Assume you are to receive a 10-year annuity with annual payments of $800. The first payment will be received at the end of year 1, and the last payment will be received at the end of year 10. You will invest each payment in an account that pays 7 percent compounded annually. Although the annuity payments stop at the end of year 10, you will not with draw any money from the account until 20 years from today, and the account will continue to earn 7 percent for the entire 20-year period. What will be the value in your account at the end of year 20 (round to the nearest dollar)

In: Finance

Bond A is a 10% coupon bond with a face value of $1,000 and a maturity...

Bond A is a 10% coupon bond with a face value of $1,000 and a maturity of 3 years. The discount rate (required return, or interest rate) is 8% now or in the future.

A. What is the bond price now, in year 1, in year 2, and in year 3

     (P0,P1,P2 and P3)?

B. If you buy the bond now and hold it for one year, what is the

     (expected) rate of return?

C. If you buy the bond at year 1 and hold it for one year, what is

    the (expected) rate of return?

D. If you buy the bond now and hold it until its maturity, what is

    the (expected) rate of return?

In: Accounting