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
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,
Next,
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 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 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].
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]
In: Computer Science
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:
Constructors:
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:
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…
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 in a Cartesian plane (but x and y should be ints). Point should have the following:
Data:
Constructors:
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:
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…
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) |
$(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 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 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 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