Please provide a multi lined pseudo code for the program below.....also it is giving me a build error? Could you possibly tell me how to fix the error too?
#include <iostream>
#include <string>
using namespace std;
class ship {
public:
string name;
int year;
ship(string n, int y) {
name = n;
year = y;
}
int getYear() {
return year;
}
string getName() {
return name;
}
void setYear(int y) {
year = y;
}
void setName(string n) {
name = n;
}
void print() {
cout << "Name: " << name << "\tYear" << year << endl;
}
};
class cruiseShip : public ship {
public:
int maxPassengers;
cruiseShip(string n, int y, int p) : ship(n, y) {
maxPassengers = p;
}
int getMaxPassengers() {
return maxPassengers;
}
void setMaxPassengers(int p) {
maxPassengers = p;
}
void print() {
cout << "Name: " << name << "\tMaxPassengers" << maxPassengers << endl;
}
};
class cargoShip : public ship {
public:
int tonn;
cargoShip(string n, int y, int p) : ship(n, y) {
tonn = p;
}
int getTonn() {
return tonn;
}
void setTonn(int p) {
tonn = p;
}
void print() {
cout << "Name: " << name << "\tTonn" << tonn << endl;
}
};
void print(ship *ships[6]) {
for (int i = 0; i < 6; i++) {
ships[i]->print();
}
}
void printOldestShip(ship *ships[6]) {
int oldest = 9999;
ship *old;
for (int i = 0; i < 6; i++) {
if (ships[i]->getYear() < oldest) {
oldest = ships[i]->getYear();
old = ships[i];
}
}
cout << "Oldest: ";
old->print();
}
int main() {
ship *ships[6];
ship s1("basic1", 1911);
ship s2("basic2", 1951);
cruiseShip c1("c1", 1970, 150);
cruiseShip c2("c2", 1990, 1000);
cargoShip cd1("CD1", 2000, 1000);
cargoShip cd2("CD2", 2010, 3000);
ships[0] = &s1;
ships[1] = &s2;
ships[2] = &c1;
ships[3] = &c2;
ships[4] = &cd1;
ships[5] = &cd1;
print(ships);
printOldestShip(ships);
return 0;
}
If you have any doubts, please give me comment...
#include <iostream>
#include <string>
using namespace std;
class ship
{
public:
string name;
int year;
ship(string n, int y)
{
name = n;
year = y;
}
int getYear()
{
return year;
}
string getName()
{
return name;
}
void setYear(int y)
{
year = y;
}
void setName(string n)
{
name = n;
}
void print()
{
cout << "Name: " << name << "\tYear" << year << endl;
}
};
class cruiseShip : public ship
{
public:
int maxPassengers;
cruiseShip(string n, int y, int p) : ship(n, y)
{
maxPassengers = p;
}
int getMaxPassengers()
{
return maxPassengers;
}
void setMaxPassengers(int p)
{
maxPassengers = p;
}
void print()
{
cout << "Name: " << name << "\tMaxPassengers" << maxPassengers << endl;
}
};
class cargoShip : public ship
{
public:
int tonn;
cargoShip(string n, int y, int p) : ship(n, y)
{
tonn = p;
}
int getTonn()
{
return tonn;
}
void setTonn(int p)
{
tonn = p;
}
void print()
{
cout << "Name: " << name << "\tTonn" << tonn << endl;
}
};
void print(ship *ships[6])
{
for (int i = 0; i < 6; i++)
{
ships[i]->print();
}
}
void printOldestShip(ship *ships[6])
{
int oldest = 9999;
ship *old;
for (int i = 0; i < 6; i++)
{
if (ships[i]->getYear() < oldest)
{
oldest = ships[i]->getYear();
old = ships[i];
}
}
cout << "Oldest: ";
old->print();
}
int main()
{
ship *ships[6];
ship s1("basic1", 1911);
ship s2("basic2", 1951);
cruiseShip c1("c1", 1970, 150);
cruiseShip c2("c2", 1990, 1000);
cargoShip cd1("CD1", 2000, 1000);
cargoShip cd2("CD2", 2010, 3000);
ships[0] = &s1;
ships[1] = &s2;
ships[2] = &c1;
ships[3] = &c2;
ships[4] = &cd1;
ships[5] = &cd1;
print(ships);
printOldestShip(ships);
return 0;
}

Please provide a multi lined pseudo code for the program below.....also it is giving me a...
Ship, CruiseShip, and CargoShip Classes (in C++ language i use visual studios to code with) design a Ship class that has the following members: - A member variable for the name of the ship (a string) - A member variable for the year that the ship was built (a string) - A contsructor and appropriate accessors and mutators - A virtual print function that displays the ship's name and the year it was built (nobody seems to get this part...
I keep getting the compilation error: pass the filename from command line arguement... Can you please tell me what im doing wrong? here is the code: import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ShipDemo { public static void main(String[] args) { String companyName; int num_ships, total_passengers=0, total_tonnage=0; Ship[] shipInventory; try { if(args.length == 1) { File file = new File(args[0]); Scanner fileScan = new Scanner(file); companyName = fileScan.nextLine(); num_ships = fileScan.nextInt(); shipInventory = new Ship[num_ships]; int n=0; String type,name;...
Program Challenge 10 Design a Ship class that the following members: · A field for the name of the ship (a string). · A field for the year that the ship was built (a string). · A constructor and appropriate accessors and mutators. · A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: · A field for the...
Hi there! I need to fix the errors that this code is giving me and also I neet to make it look better. thank you! #include <iostream> #include <windows.h> #include <ctime> #include <cstdio> #include <fstream> // file stream #include <string> #include <cstring> using namespace std; const int N=10000; int *freq =new int [N]; int *duration=new int [N]; char const*filename="filename.txt"; int songLength(140); char MENU(); // SHOWS USER CHOICE void execute(const char command); void About(); void Save( int freq[],int duration[],int songLength); void...
Show the compilation of Programming Challenge below in separate header and implementation files and show a UML diagram of this class. #include “Car.h” Int main() { Car car(2015, “Volkswagon”); Cout<<”Car’s Make: “ << car.getMake() <<endl; Cout<< “Car’s Year:” << car.getYear() <<endl; Cout<< “Car’s Speed : “ <<car.getSpeed()<<endl; Cout<< endl; For(int I =0; I < 5; i++) { Car.acceleration(); Cout<< “Speed after accelerate: “ << car.getSpeed() << endl; } For(int I = 0; i < 5; i++) { Car.brake(); Cout <<...
hello there. can you please help me to complete this code. thank you. Lab #3 - Classes/Constructors Part I - Fill in the missing parts of this code #include<iostream> #include<string> #include<fstream> using namespace std; class classGrades { public: void printlist() const; void inputGrades(ifstream &); double returnAvg() const; void setName(string); void setNumStudents(int); classGrades(); classGrades(int); private: int gradeList[30]; int numStudents; string name; }; int main() { ...
c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...
This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...
previous assignment code /*C++ test program to test the classes, Animal, Mammal and Cat and print the results on console window.*/ //Main.cpp //include header files #include<iostream> //include Animal, Mammal and Cat header files #include "Animal.h" #include "Mammal.h" #include "Cat.h" using namespace std; int main() { //create Animal object Animal animal("Dog","Mammal",4); cout<<"Animal object details"<<endl; cout<<"Name: "<<animal.getName()<<endl; cout<<"Type: "<<animal.getType()<<endl; cout<<"# of Legs: "<<animal.getLegs()<<endl; cout<<endl<<endl; //create Cat object Cat cat("byssinian cat","carnivorous mammal",4,"short...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...