这个程序怎么写出来的啊?

The scenario for the lab is a simplified Car Insurance Company and insurance policies. You will work on the same scenario throughout the session for all the labs and the assignments. Study week 1 lecture codes in depth before attempting the lab:
Car has these attributes:

  • String model;
  • CarType type; // CarType is an enum { SUV,SED,LUX,HATCH,etc }
  • int ManufacturingYear;
  • double price;
    There are two different types of Insurance Policies: ThirdPartyPolicy and ComprehensivePolicy.
    All Policies have the following attributes in common (The parent class: InsurancePolicy):
  • String policyHolderName;
  • int id;
  • Car car;
  • int numberOfClaims;

ThirdPartyPolicy class has the following additional attributes:

  • Sting comments;

ComprehensivePolicy class has the following additional attributes:

  • int driverAge;
  • int level;

The premiums for each policy is calculated as follow:
• Third Party Premium = CarPrice/100+numberOfClaims x 200+flatRate
• Comprehensive Premium = CarPrice/50+numberOfClaims x 200+flatRate
o If the driverAge is less than 30 then add (30-driverAge) x 50 to the comprehensive premium
The flatRate will be set by the manager and will be sent to the calculation from outside as a parameter (currently from test code in main).

1- Write the Java code to define the class Car as well as enum CarType.

2- Write an abstract base class called InsurancePolicy for the above scenario. This class supports the common features of all policies.

4- Write two sub classes called ThirdPartyPolicy and ComprehensivePolicy for the scenario.

5- Write a print method for these classes. Use super.print ( ) in children classes.

5- Override the calcPayment method based on the description for Premium Payment.

6- Add toString() to all classes.
7- Write a test code that creates a mixture of ThirdPartyPolicy and ComprehensivePolicy objects, then places them in a single list of policies, print all the policies in the list by using print method and then by using toString method. Then calculates their total premium payments and finally prints the total with user friendly prompts. Note that the flatRate should be stored as a constant in your test code and then is sent it to the methods as a parameter.

虽然我没有仔细看完,但这应该是常见的面向对象练习题之小汽车问题
创建出对应的类和类中方法,然后完成最后的方法调用操作即可

用的的知识:类、对象使用