forked from Davincii254/Space-Program-using-Obj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnested.js
More file actions
46 lines (39 loc) · 1.39 KB
/
Copy pathnested.js
File metadata and controls
46 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const artcaffe = {
name: "Artcaffe",
location: "Ngong Rd",
menu: {
coffe: {
name: "Capuccino",
price: 500,
isHot: true
},
pastry: {
name: "Chocolate croisant",
price: 200,
topping: "More chocolate"
}
},
};
console.log(`Todays food is ${artcaffe.menu.pastry.name}.`)
console.log(`Todays topings is ${artcaffe.menu.pastry.topping}.`)
console.log()
// 4. Find and inspect a specific ship (using the findShip method)
const cruiser = terminusSpaceport.findShip(2);
if (cruiser) {
console.log(`Found Ship in Bay ${cruiser.bayId}: ${cruiser.getRegistryName()}`);
console.log(`Fuel Status: ${cruiser.fuelLevel}% Full`);
// You can even modify data directly on the found object
cruiser.fuelLevel = 90;
console.log(`[UPDATE] Voyager-099 fuel topped off to ${cruiser.fuelLevel}%!`);
}
// 5. Delete a ship from the manifest (using the deleteShip method)
console.log("\n--- Ship Departure ---");
terminusSpaceport.deleteShip(1); // ShipA departs
// 6. Attempt to find the departed ship
const departedShip = terminusSpaceport.findShip(1);
if (!departedShip) {
console.log("[STATUS] Cannot locate ship in Bay 1. Manifest is up to date.");
}
// 7. Show the final manifest (The 'ships' collection)
console.log("\n--- FINAL MANIFEST (Remaining Ships) ---");
console.log(terminusSpaceport.ships);