1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olchik [2.2K]
2 years ago
11

Your solution should for this assignment should consist of five (5)files:============================================== FuelGaug

e.h (class specification file)FuelGauge.cpp (class implementation file)Odometer.h (class specification file)Odometer.cpp (class implementation file)200_assign6.cpp (application program)=================================================★ For your sixth programming assignment, you will be implementing a program that uses two(2)classes that work together to simulate a car’s fuel gauge and odometer. The classes you will design are: TheFuelGaugeClass: This class will simulate a fuel gauge. Its responsibilities are↘To know the car’s current amount of fuel, in gallons.↘To report the car’s current amount of fuel, in gallons.↘To be able to increment the amount of fuel by 1 gallon. This simulates putting fuel in the car. (The car can hold a maximum of 15 gallons)↘To be able to decrement the amount of fuel by 1 gallon, if the amount of fuel is greater than 0 gallons. This simulates burning fuel as the car runs.TheOdometerClass: This class will simulate the car’s odometer. Its responsibilities are:↘To know the car’s current mileage.↘To report the car’s current mileage.↘To be able to increment the current mileage by 1 mile. The maximum mileage the odometer can store is 999,999 miles. When this amount is execeeded, the odometer resets the current mileage to 0.↘To be able to work with aFuelGaugeobject. It should decrease theFuelGaugeobject’s current amount of fuel by 1 gallon for every 24 miles traveled. (The car’s fuel economy is 24 miles per gallon)The FuelGaugeclass should have at least one constructor, and the appropriate member functions to get the number of gallons, increment the number of gallons, and decrement the number of gallons.★ The odometer class should have at least one constructor, and the appropriate member functions to get the mileage and increment the mileage (unfortunately you cannot decrement the mileage!).★ In the odometer class, you can have a member variable that is a pointer to a FuelGauge object. This is how you can establish a relationship between the two classes that allow them to work together. For every mile the car is driven, the odometer is increased by 1, and for every 24 miles the car is driven, the number of gallons is reduced by one.★ So in the Odometer class, one of the private member variables should be of type fuel gauge* (pointer to a FuelGauge object).★ Demonstrate the two classes by creating instances(objects)of each. Simulate filling the car up with fuel, and then run a loop that increments the odometer until the car runs out of fuel. During each loop iteration, print the car’s current mileage and amount of fuel.
Computers and Technology
1 answer:
olga nikolaevna [1]2 years ago
6 0

Answer: provided in the explanation section

Explanation:

This was implemented in C++

Filename: Car.cpp

#include <iostream>

#include <iomanip>

#include <cstdlib>

#include "Odometer.h"

using namespace std;

int main()

{

  char response;

  do

  {

      FuelGuage* myFuel = new FuelGuage(6);

      int fuelLevel = myFuel->getFuel();

      cout << "Car gas level: " << fuelLevel << endl;

      cout << "Car is filling up" << endl;

      while(myFuel->getFuel() < 15)

      {

          myFuel->addFuel();

      }

      Odometer* car = new Odometer(myFuel, 999990);

      cout << "Car gas level: " << car->getFuelGuage()->getFuel() << endl;

      cout << "Car is off!" << endl;

      cout << "--------------------------" << endl;

      while(car->getFuelGuage()->getFuel() > 0)

      {

          car->addMile();

          int miles = car->getMileage();

          cout << "Mileage: " << setw(6) << miles << ", Fuel Level: " << car->getFuelGuage()->getFuel() << endl;

          cout<<"--------------------------------------------------------------"<<endl;

      }

      delete myFuel;

      delete car;

      cout << "Would you like to run the car again(Y/N)? ";

      cin >> response;

      system("cls||clear");

  } while(toupper(response) != 'N');

  return 0;

}

Filename: FuelGuage.cpp

#include "FuelGuage.h"

FuelGuage::FuelGuage()

{

  init();

}

FuelGuage::FuelGuage(int fuel)

{

  init();

  this->fuel = fuel;

}

FuelGuage::FuelGuage(const FuelGuage& copy)

{

  this->fuel = copy.fuel;

}

void FuelGuage::init()

{

  this->fuel = 0;

}

int FuelGuage::getFuel()

{

  return fuel;

}

void FuelGuage::addFuel()

{

  fuel++;

}

void FuelGuage::burnFuel()

{

  fuel--;

}

Filename:FuelGuage.h

#ifndef FUEL_GUAGE_H

#define FUEL_GUAGE_H

class FuelGuage

{

private:

  int fuel;

  void init();

public:

  FuelGuage();

  FuelGuage(int fuel);

  FuelGuage(const FuelGuage& copy);

  int getFuel();

  void addFuel();

  void burnFuel();

};

#endif

Filename : Odometer.cpp

#include "Odometer.h"

Odometer::Odometer()

{

  init();

}

Odometer::Odometer(FuelGuage* inFuel, int inMileage)

{

  init();

  this->fuel = new FuelGuage(*inFuel);

  this->mileage = inMileage;

  this->milesSinceAddingFuel = 0;

}

void Odometer::init()

{

  fuel = new FuelGuage();

  mileage = 0;

  milesSinceAddingFuel = 0;

}

FuelGuage* Odometer::getFuelGuage()

{

  return fuel;

}

int Odometer::getMileage()

{

  return mileage;

}

void Odometer::addMile()

{

  if(mileage < 999999)

  {

      mileage++;

      milesSinceAddingFuel++;

  }

  else

  {

      mileage = 0;

      milesSinceAddingFuel++;

  }

  if((milesSinceAddingFuel % 24) == 0)

  {

      fuel->burnFuel();

  }

}

void Odometer::resetMiles()

{

  milesSinceAddingFuel = 0;

}

Odometer::~Odometer()

{

  delete fuel;

}

Filename: Odometer.h

#ifndef ODOMETER_H

#define ODOMETER_H

#include "FuelGuage.h"

class Odometer

{

private:

  void init();

  int mileage;

  int milesSinceAddingFuel;

  FuelGuage* fuel;

public:

  Odometer();

  Odometer(FuelGuage* inFuel, int inMileage);

  FuelGuage* getFuelGuage();

  int getMileage();

  void addMile();

  void resetMiles();

  ~Odometer();

};

#endif

You might be interested in
Select the correct statement(s) regarding partial mesh networks.
sweet [91]

Answer: all the answers are correct

Explanation:

Partial mesh networks is simply a packet switching networks which is connected and require that there should be establishment of a circuit before the exchange of packets.

Partial mesh networks are less expensive to implement when they're being compared to the full mesh networks and are also less redundant.

The correct statements regarding partial mesh networks are:

•the number of links connecting nodes in a partial mesh network depends upon the availability and reliability requirements of the network

• switches play an integral role in a partial mesh network, where several paths through the network are available

• redundant links and switches are used to improve the availability and reliability of partial mesh networks

6 0
3 years ago
Dzięńdobry kto ogarnia komędy w minicraft bardzo dobrze i by mi pomógł w stworzeniu serwera [dostanie w zamian range właścieciel
mojhsa [17]

Playing Minecraft on a public server can take the game to a whole. This will help your kid learn social skills, such as cooperating, while there are some family-friendly servers for the Pocket Edition most server admins can “roll back” your building to the state it was in.

Explanation:

  • For Minecraft, you'll need to forward TCP port 25565 . You'll also need to enter your server's local IP address as the Output IP or Server IP for the forwarded port. This tells the router which device to point at. To find your server's local IP, open a command prompt and enter ipconfig.
  • They are safe for the most part, however they do expose you to the following risks, which can generally be negated by simply joining reputable servers. Some servers may ask users to set up an AuthMe password. If you decide to enter a password here, never ever enter the password of your Minecraft account.
  • You can divide public Minecraft servers into two types:
  1. Whitelisted servers are protected by a whitelist — that is, a list of usernames that are allowed to join the server. To join a whitelisted server, you need to apply to have your Minecraft username added to the whitelist. Typically, this involves filling out a form and waiting a few hours or days.
  2. Non-whitelisted servers do not have a whitelist, which means anyone can join the server simply by entering the server’s address in their Minecraft client, as shown above.
  • Applying for a whitelisted server can be a bit of a drag especially when you have an impatient eight-year-old tugging at your sleeve but it does provide an extra degree of reassurance that all the players on the server are known to the server administrators.
8 0
3 years ago
A switch that is configured to use the Spanning Tree Protocol will place a port in ____________ mode if sending traffic to it ma
Rashid [163]

Answer:

Blocking Mode    

Explanation:

Spanning Tree Protocol is used to allow path redundancy in the network without creating cycles/circles also called loops.

When two parts of the switched network are connected via two or more Layer 2 switches this result in a loop.

This affects the performance of the network as the result of broadcast packets flooding.

STP puts one port of the switch to forwarding mode and the rest of the ports within the same part of the network to the blocking mode to avoid broadcast packet flooding. STP puts all the ports that are allowing redundant paths to blocking mode and the one port that is left after this is placed in forward mode.

Spanning Tree Algorithm is used by STP to determine the optimal path  of switch to the network.

Bridge Protocol Data Units are used to share the information about the optimal path determined by the spanning tree algorithm with other switches.

This information helps STP to eliminate the redundant paths.

So this is how STP allows only one active path to the destination while blocking all other paths to avoid switching loop.

6 0
3 years ago
Worms often try to disguise from where they are sending data by using a bogus ip addresses instead of using an authorized ip add
Katyanochek1 [597]

If the question is asking whether it is true or false, the answer is false because worms are not responsible for disguising when they are sending data by using bogus ip addresses but it is the Trojan horses in which they are the one responsible for misleading users from the true intent or the real data.

5 0
3 years ago
(tco 7) the .net framework class library consists of ________ that provide many of the functions that you need for developing .n
Andre45 [30]
Code, which makes it work.
5 0
3 years ago
Other questions:
  • Due to the internal style sheets of some browsers, your website may look different to someone who is using firefox as opposed to
    11·1 answer
  • What encryption method is used by WPA for wireless networks?
    7·1 answer
  • What does psychologist Edward Spector mean when he says “ We have an entire generation of guinea pigs in an experiment”?
    14·1 answer
  • You have created a new dhcp scope with address range 192.168.1.1 to 192.168.1.254. you have five servers configured with static
    9·1 answer
  • The force required to slide an object is equal to _____.
    13·1 answer
  • Do like TikTok??????
    14·2 answers
  • Which best describes how a supporting database will be structured?
    10·1 answer
  • Write a short essay on the importance of information and communication technology (ICT) in the AFN industry. Add suitable exampl
    11·1 answer
  • When you type in text in an image in a photo-editing software, where is it created?
    8·1 answer
  • Explain the concept of conditional formatting​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!