Em mới học java được giao 1 bài tập như sau:
Create project Java application named Computer System
- Create package named com.bkap.machine and create some classes in this package following.
- Create an abstract class named Computer that stores the following details:
- name: String data type, named machine (ex: Elitebook 2670p).
- manufac: String data type, named manufacturer (ex: Sony Vaio).
- price: float data type, price of computer (ex: 123.99).
- warranty: integer data type, warranty months of computer (ex: 12).
- In this class, create two abstract methods named inputData() and printInfo().
- Create two class named HPComputer and DellComputer is extended from Computer class. In classes
above, override two methods inputData() for input data and printInfo() for show data of computer (write code
with same function input and output in method). - Create a Java main class named ComputerManager has method print menu as following:
…: MENU :… - Input computer list.
- View computer list.
- Sort computer list by warranty.
- Sort computer list by name.
- Exit.
- In this class, create a array containable 5 Computer and create methods implement some tasks
which follow menu above:
- Input list (ask for user want HP or Dell then create object by same class)
Em có thắc mắc về đoạn “create a array containable 5 Computer” vì không thể tạo 1 đối tượng từ 1 lớp trừu tượng
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?