Advertisement
Guest User

Untitled

a guest
Jun 8th, 2019
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. Define two classes Car and Engine. A Car has a model, engine, weight and color. An Engine has model, power, displacement and efficiency. A Cars weight and color and its Engine’s displacements and efficiency are optional.
  2. On the first line, you will read a number N which will specify how many lines of engines you will receive, on each of the next N lines you will receive information about an Engine in the following format "<Model> <Power> <Displacement> <Efficiency>". After the lines with engines, on the next line you will receive a number M – specifying the number of Cars that will follow, on each of the next M lines the information about a Car will follow in the following format "<Model> <Engine> <Weight> <Color>", where the engine in the format will be the model of an existing Engine. When creating the object for a Car, you should keep a reference to the real engine in it, instead of just the engines model, note that the optional properties might be missing from the formats.
  3. Your task is to print each car (in the order you received them) and its information in the format defined bellow. If any of the optional fields has not been given print "n/a" in its place instead of:
  4. <CarModel>:
  5. <EngineModel>:
  6. Power: <EnginePower>
  7. Displacement: <EngineDisplacement>
  8. Efficiency: <EngineEfficiency>
  9. Weight: <CarWeight>
  10. Color: <CarColor>
  11. Optional
  12. Override the classes ToString() methods to have a reusable way of displaying the objects.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement