Mình thấy bạn có hỏi 1 bài khác ở đây: toString trong java
Để có thể làm đúng đc yêu cầu bước đầu tiên phải thiết kế các class đúng theo đề bài đã.
Dịch thì bạn có thể dùng google dịch, hoặc bất kì phương tiện nào, nhiều lắm nên mình sẽ không dịch toàn bộ mà chỉ note lại những thứ cần quan tâm:
The media archive has music recordings on the following media: CDs, USB sticks, compact cassettes and LPs.
=> Bốn đối tượng CD, USBStick, CompactCassettes và LP sẽ kế thừa 1 đối tượng abstract là Media
The media have partly different characteristics:
• A CD can be writable (attribute).
• A USB stick has a format such as NTFS, ext4, FAT, FAT32
• A Compact Cassette may be single-sided or double-sided.
• An LP has a diameter and a given rotation speed.
=> Mô tả các field trong từng đối tượng
The archived CDs and USB sticks are digital media that have a data size
=> CD, USBStick extends DigitalMedia extends Media. Trong DigitalMedia có 1 field là dataSize
The other two media are analog media and can be recorded in stereo or mono
=> CompactCassette, LP extends AnalogMedia extends Media. Trong AnalogMedia có 1 field là recoredType
The digital and analog media store audio files that have a name and are created by an artist. In addition to the number of pieces of music, the total playing time of the stored pieces of music of each audio medium is relevant.
=> Chính là thông tin của đối tượng tổng quát nhất Media: name, createdBy, numberOfMusic, totalPlayingTime
All music is managed in a central media archive, which performs various tasks. Information about existing media must be backed up regularly and stored elsewhere. For this purpose the media archive has the possibility to create a list of all media.
=> Tạo một đối tượng MediaArchive chính là đối tượng sẽ thực hiện các công việc lq đến các Media nói trên. Nó chứa 1 List các Media
All media override the toString () method, which returns a string with a concise listing of all attribute values (status of the object). The media archive offers the possibility to output the status information of all archived media on the console
=> Khá đơn giản, có thể dịch được
A media archive method can be called with a string as a parameter indicating a media type. If there is no media for this type, a corresponding error message will be displayed. Should the type be present, e.g. “CD” calls the toString () method of all CDs managed in the Media Archive.
=> Trong MediaArchive có 1 phương thức xxx có tham số truyền vào là kiểu của media. Nếu tham số truyền vào không tương ứng với một media nào, sẽ thông báo lỗi. Nếu có, ví dụ như tham số là “CD” sẽ tương ứng với kiểu đối tượng CD, thì MediaArchive sẽ gọi hàm toString() của tất cả các đối tượng CD có trong list.
The media archive provides a method that counts all media of each type. An example output might look like this: “The stock of the media archive currently includes 20 USB sticks, 11 CDs, 44 LPs and 9 compact cassettes”
=> Đếm xem trong list có bao nhiêu media từng loại.