Question

Consider the following interface for an ADT for representing intervals (periods of time as opposed to...

Consider the following interface for an ADT for representing intervals (periods of time as opposed to instantaneous moments of time).

typedef long Duration; // measured in seconds

class DateTime {
public:
    DateTime (int year, int month, int day, int hour, int minute, int second);
    ...

    // How many seconds between two times?
    Duration operator- (const DateTime& right) const;
};


class Interval {
public:
  //
  // An interval is a period of time beginning with a starting time
  //  and running up to, but not including, its stop time.
  //
  Interval ();
  Interval (DateTime start, DateTime stop);
  Interval (DateTime start, Duration length);

  DateTime getStart() const;
  void setStart (DateTime);

  DateTime getStop() const;
  void setStop (DateTime);

  Duration getDuration();

  bool contains (DateTime d);
  bool overlaps (Interval intrvl);

  bool operator== (const Interval& other) const;
private:
  DateTime theStart, theStop;
};

Using the JUnit style, write a self-checking test for the setStart function.

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Consider the following interface for an ADT for representing intervals (periods of time as opposed to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ When running my tests for my char constructor the assertion is coming back false and...

    C++ When running my tests for my char constructor the assertion is coming back false and when printing the string garbage is printing that is different everytime but i dont know where it is wrong Requirements: You CANNOT use the C++ standard string or any other libraries for this assignment, except where specified. You must use your ADT string for the later parts of the assignment. using namespace std; is stricly forbiden. As are any global using statements. Name the...

  • In this lab, you will need to implement the following functions in Text ADT with C++...

    In this lab, you will need to implement the following functions in Text ADT with C++ language(Not C#, Not Java please!): PS: The program I'm using is Visual Studio just to be aware of the format. And I have provided all informations already! Please finish step 1, 2, 3, 4. Code is the correct format of C++ code. a. Constructors and operator = b. Destructor c. Text operations (length, subscript, clear) 1. Implement the aforementioned operations in the Text ADT...

  • Instructions: Consider the following C++ program. At the top you can see the interface for the...

    Instructions: Consider the following C++ program. At the top you can see the interface for the Student class. Below this is the implementation of the Student class methods. Finally, we have a very small main program. #include <string> #include <fstream> #include <iostream> using namespace std; class Student { public: Student(); Student(const Student & student); ~Student(); void Set(const int uaid, const string name, const float gpa); void Get(int & uaid, string & name, float & gpa) const; void Print() const; void...

  • Requirements Print a range Write a bag member function with two parameters. The two parameters are...

    Requirements Print a range Write a bag member function with two parameters. The two parameters are Items x and y. The function should write to the console all Items in the bag that are between the first occurrence of x and the first occurrence of y. You may assume that items can be compared for equality using ==. Use the following header for the function: void print_value_range(const Item& x, const Item& y); print_value_range can be interpreted in a number of...

  • in c++ please include all of the following " template class, template function, singly linked list,...

    in c++ please include all of the following " template class, template function, singly linked list, the ADT stack, copy constructor, operator overloading, "try catch"and pointers Modify the code named "Stack using a Singly Linked List" to make the ADT Stack that is a template class has the code of the destructor in which each node is directly deleted without using any member function. As each node is deleted, the destructor displays the address of the node that is being...

  • IN c++ i post this question 5 times. hope this time somebody answer.. 16.5 Homework 5...

    IN c++ i post this question 5 times. hope this time somebody answer.. 16.5 Homework 5 OVERVIEW This homework builds on Hw4(given in bottom) We will modify the classes to do a few new things We will add copy constructors to the Antique and Merchant classes. We will overload the == operator for Antique and Merchant classes. We will overload the + operator for the antique class. We will add a new class the "MerchantGuild." Please use the provided templates...

  • Introduction Welcome to Rad.io, you've been hired to work on our music streaming app, think of...

    Introduction Welcome to Rad.io, you've been hired to work on our music streaming app, think of it as Spotify only more rad! You're in charge of handling our customer’s song list. When a user selects a playlist it will load into the list a number of songs. Users can skip to the next song, move to the previous, they can select a song to play next or select a song to add to the end of their list. Objective You...

  • Hi I need a fix in my program. The program needs to finish after serving the...

    Hi I need a fix in my program. The program needs to finish after serving the customers from the queue list. Requeriments: Headers: DynamicArray.h #ifndef DynamicArray_h #define DynamicArray_h #include using namespace std; template class DynamicArray { V* values; int cap; V dummy; public: DynamicArray(int = 2); DynamicArray(const DynamicArray&); ~DynamicArray() { delete[] values; } int capacity() const { return cap; } void capacity(int); V operator[](int) const; V& operator[](int); DynamicArray& operator=(const DynamicArray&); }; template DynamicArray::DynamicArray(int cap) { this->cap = cap; values =...

  • Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p;...

    Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...

  • Template Deque Class (C++) In this assignment, we will use a given test menu for the template Deq...

    Template Deque Class (C++) In this assignment, we will use a given test menu for the template Deque Class (a Linked List based Double Ended Queue, Deque) that you have put together. Recommended Steps testDeque.cpp : // C++ implementation of doubly linked list Deque doubly linked list #include <bits/stdc++.h> using namespace std; class Timer { // To replace with the full timer class definition // inside this folder: LearnCpp9_18_timeSortArray.cpp }; // Node of a doubly linked list template<class T> class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT