Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
C Sharp, I am trying to get my console to display the vehicle information, by using a base class of Vehicle and derived classes Car, and Truck. I have to add an interface to add and remove cars. But for now, I am just trying to get the vehicle information to display from the Car class. For some reason I am not able to override my methods in the derived classes. What am I am doing wrong ? using CarRentalCompany;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CarRentalCompany
{//Define an abstract class Vehicle with properties like Make, Model, Year, Status, and Notes
public abstract class Vehicle
{
public string make;
public string model;
public int year;
public string status;
public string notes;
//Method to Display vechile information
public void DisplayVehicleInfomration() { }
}
public class Car : Vehicle, IRentable
{
private string v;
public Car(string v)
{
this.v = v;
}
//Construtor new object is created
public Car(string make, string model, int year, string status, string notes)
{
this.make = make;
this.model = model;
this.year = year;
this.status = status;
this.notes = notes;
}
//
public override void DisplayVehicleInfomration()
{
Console.WriteLine("The make of this vechile is + {make} ");
Console.WriteLine($"The model of the vechile is + {model}");
Console.WriteLine($"The yerr of the vechile is + {year}");
Console.WriteLine($"The status of the vechile is + {status}");
Console.WriteLine($"Vechile notes : + {notes}");
}
}
public class Truck : Vehicle, IRentable
{
public Truck (string make, string model, int year, string status, string notes)
{
this.make = make;
this.model = model;
this.year = year;
this.status = status;
this.notes = notes;
}
//Why can't I override ?
public override void DispalyVechileInfomration() {
}
}
}
//Use an interface IRentable for vehicles that can be rented,
////including methods like Rent and Return.
///Create the name with an I in front and Capital the 1st letter = Interface
///Interfaces are public - so no need to add modifers
public interface IRentable
{
// CarRent();
// CarReturn();
};
using CarRentalCompany;// make sure to list other classes here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// need to fix name spacing // How do I fix the namespaces ?
namespace CarRentalCompnay
{
class ProgramA
{
static void Main(string[] args)
{ ////Store the objects in a Collection object (List, Array, HashSet, etc...) objects in the collection will be of type Shape
Vehicle[] arrayOfVehicles = new Vehicle[5];
arrayOfVehicles[0] = new Car("Toytoa, Camery, 2024,available, notes: Scratch on driver side door ");
arrayOfVehicles[1] = new Car(" ");
arrayOfVehicles[2] = new Car(" ");
// arrayOfVehicles[3] = new Truck(" ");
// arrayOfVehicles[4] = new Truck("");
foreach (Vehicle vehicle in arrayOfVehicles)
{//How do I get my console to dispaly car information ?
Console.WriteLine($" The current {vehicle} is a ");
}
}
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Your task will be to create a simple text-based simulation that inherits from a pre-existing World class. You must use the World.h provided as a starting point for your code. At least one object in your solution should meaningfully inherit from this class. DO NOT MODIFY THE WORLD CLASS in any way. Note that the World class is abstract and there are a few pure virtual functions for you to implement in your object that inherits from the world. Namely, you will need to implement: void PrintGrid() - This function should print the grid (10 by 10 char array) to standard out. void UpdateGrid() - This function should update your characters' positions on the grid void initGrid() - This function should set your grid up (implement your "starting conditions" here) The scenarios that you will simulate will be confined to a 10x10 grid (defined in the World class as grid) and be subject to at least 10 distinct rules. In addition, there must be at least 2 different objects or “characters”…arrow_forwardi have got my one solution . thank you sir. as rules you've asked me to submit my another question once more. so, this is my another question .i hope soon i will get my ans for this question also. thank you again sir.arrow_forwardFor a parking management system, use the Observer pattern to implement this interaction using Java and implement the three classes mentioned below. Implement a ParkingObserver that has the role of the Observer. The Observable classes (Subjects) will be the ParkingLots. It would be helpful if the notify method in the subjects (and update method in the observers) took a parameter, perhaps an object of type ParkingEvent, which could have fields including the lot, timeIn, timeOut (if relevant), and permit. The ParkingObserver should register with each ParkingLot and receive the messages. Once a car enters (in an entry-scan only lot) or leaves (in an entry-scan and exit-scan lot), then the ParkingObserver will be updated, and then can register the charge with the parking system via the TransactionManager’s park() method. Based on these requirements you should implement three actor classes in this interaction using java: TransactionManager, ParkingObserver and ParkingLot. 1. The…arrow_forward
- To be considered "good," an interface's set of features must be comprehensive. Which skills are absolutely necessary? Is it the intention to standardize on one approach? Provide evidence by citing concrete examples to back up your views.arrow_forwardPlease give the class diagram of the system and see if there is any problem in the operation of the classesarrow_forwardFor this exercise, you are given a Team superclass with a BaseballTeam and FootballTeam subclass. Take a moment to examine these classes and the instance variables and methods in each. In the TeamTester class, you will see three objects declared and instantiated using the Team, FootballTeam, or BaseballTeam classes. For each object, use a print statement to print out any public method that returns information that is available for that particular object, including the toString. For example, the dolphin object is a FootballTeam object. One of the pieces of information that can be printed is the getTies() method, so you will call that method in your TeamTester file: System.out.println(dolphins.getTies()); Do this for all the methods that each of the objects can call. Hint: Remember, for the program to compile and run, Java looks for methods to exist in certain classes. ================================= public class Team { private String name;private String location;private int…arrow_forward
- Every interface worth its salt must provide access to a full suite of functions. What abilities do you need to have? Is it planned to use a single method across the board? Document your claims by citing appropriate earlier research.arrow_forwardIn JavaScript, how are an object and an interface related to each other? a. The object’s interface consists of the code and data needed for that object. b. An object’s interface is analogous to a pocket calculator’s inner workings. c. Built-in JavaScript objects do not require an interface, but custom objects do. d. An interface allows another program to access an object’s properties and methods.arrow_forwardB elow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods. For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate…arrow_forward
- Help, I am making a elevator simulation using polymorphism. I am not sure to do now. Any help would be appreciated. My code is at the bottom, that's all I could think off. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. public abstract class Passenger { public static int passangerCounter = 0; private String passengerID; protected…arrow_forwardUse java programming properties to write all the necessary classes and/or interfaces for a solution to the problem. Focus on class structure and interaction. You may implement your solution however you wish, but you will be graded on the appropriateness of your solution to the requirements. Note the use of capitalization and parentheses for clarification. You may use whatever constructors or additional methods you wish. Define a structure that can represent Animals. Animals have two behaviors; they can speak() and they can move(). By default, when an animal moves, the text ”This animal moves forward” is displayed. By default, when an animal speaks, the text ”This animal speaks” is displayed. A general Animal should not be able to be instantiated. Define two classes, Goose and Lynx, that are Animals. Both Goose and Lynx behave such that where “Animals” is displayed in speak() or move(), “goose” or “lynx” is displayed by the appropriate classes. Finally, any instance of Goose can fly(),…arrow_forwardAfter drawing the hierarchy, implement the classes by writing C# code foreach class. Then create objects of each class and call ALL methods onthese objects.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education