Schaum’s Outline Series OF Principles of Computer Science phần 10

bất kỳ hàng nào thật nếu tất cả của một tập hợp các so sánh là đúng thật nếu có một trong một bộ so sánh là đúng thật nếu một số của một tập hợp các so sánh trồng thủy Điều này sẽ báo cáo các chuyên ngành CS trong thứ tự chữ cái theo tên. Để sắp xếp theo thứ tự chữ cái đảo ngược, thêm giảm dần từ (giảm dần) ở cuối của câu truy vấn | ANSWERS TO REVIEW QUESTIONS 197 v1 new Vehicle Ford Mustang 2 red v2 new Vehicle BMW 328i 4 silver v3 new Vehicle Chrysler PT Cruiser 4 gold There are vehicles. Make of v1 Ford Model of v2 328i Color of v3 gold Max occupants of v1 2 double accel 70. accelerated by accel mph to mph. Chevrolet Malibu white 60. v1 is now a going mph. v4 new Skateboard Mako Shark red accel 5. v4 is a Skateboard going mph. accel 22. The Skateboard is now going mph. 295. should be mpg The mileage try Refueling skateboard 0. 5. catch Exception e Write a class that extends Exception and is called TooManyOccupantsException. Have the Vehicle class mutator for number of occupants throw such an exception if the numberOfOccupants would exceed the maximum number of occupants for the vehicle. What will you need to change in your ManyVehicles test class 198 ANSWERS TO REVIEW QUESTIONS public class TooManyOccupantsException extends Exception TooManyOccupantsException int occupantCount super Vehicle cannot accommodate occupantCount In ManyVehicles test class try adding people to Ford 6 catch Exception e Change your ManyVehicles class so that it reads from a text file called the specifications for the Vehicles to create. Use a BufferedReader or a Scanner to read the file. Using a Scanner is probably easier in this case. Here is a

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.