CS102A 2019

Posted bizhui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CS102A 2019相关的知识,希望对你有一定的参考价值。


CS102A 2019Fall Assignment5
Keyword Annotation:
Field(s): You can see the field(s) you need to define after it.
Method(s): You can see the method(s) you need to define or modify after it.

Question1 Simple Parking System

General Description

In the Parking lot, we can add parking space for SmallCar, LargeCar or any arbitrary subclass of Car. When the cars enters the parking lot, the size of specific kind of car will be deducted. When the cars leave out of the parking lot, parking fees should be paid.

It is only a simple Parking System for exercising the interface, abstract class, inheritance, polymorphism, wildcard, etc. The implement of Parking System in real world would be more complex than our assignment.

You need to define or modify following classes

1. class Time

Fields:

private int hour

private int minute

Methods:

public Time timeDifference(Time time)
return a new object of Time that indicates the difference between two time.
For example, the difference between 06:30 and 07:45 is 01:15.

public Time fewMinutesLater(int minutes)
return a new object of Time that indicates the time of several minutes later.
For example, if the current time is 06:30, time.fewMinutesLater(50) is 07:20.

public String toString()
Override method which returns a format type of String as "hour:minutes" such as 01:15, 10:02 or 23:59.

Do not modify or remove any methods or fields that have been already defined.
You can add other methods or attributes that you think are necessary.
2. class Car

It is an abstract class, which is the super class of other Concrete Car classes.
Fields:

private String plateNumber
Plate number of the car. It must have a prefix of "粤B". We can make sure that our test cases of plate number are all prefixed with "粤B" then appended five-digital integers.

private Time arriveTime
A Time type that record the arriving time of the car.

Do not modify or remove any methods or fields that have been already defined.
You can add methods or attributes that you think are necessary.
3. class SmallCar &. class LargeCar

Those are the subclasses of the class Car.
Field:

private boolean deduction
Only defined in class SmallCar**. If the last character of the plate number is an even number, the deduction is true, otherwise, the deduction is false.

Methods:

public String toString()
Override this method in each subclass. The output must be ClassName plateNumber ArriveTime (each output element are separated by only one space), and the if the deduction of a small car is true, the output must be ClassName plateNumber ArriveTime deducted.
For example:


SmallCar 粤B11113 01:55
SmallCar 粤B11114 01:55 deducted
LargeCar 粤B21111 01:55
public int calculateMoney()
Override this abstract method in each subclass. The way to calculate money is shown as following table:
Three attributes of price in each car:

Price Small Car Large Car
Start Price 15 0
Increment Price 5 15
Max Price 60 100
Charges Notes:

Time(deduction) Small Car(false) Small Car(true) Large Car
Time < 30 min 0 0 0
30 min ≤ Time < 1 h Start Price 0 Increment Price
1 hour ≤ Time < 2 hours Start Price + Increment Price * hour 0 Increment Price * (hour+1)
2 hours ≤ Time Min(Start Price + Increment Price * hour , Max Price) Min(Increment Price * (hour-1) , Max Price) Min(Increment Price * (hour+1) , Max Price)
Do not modify or remove any methods or fields that have been already defined.
You can add methods or attributes that you think are necessary.
4. class ConcreteParkingLot

It is a concrete class of the interface ParkingLot, in which you need to implement all abstract methods that are declared in the interface ParkingLot. Please read the

CS102A留学生作业代做、代写Parking System作业annotations in ParkingLot.java carefully and all parameters, return values, functions of each method should be strictly followed the description in annotations. We provide Client1.java for you to understand all methods and its standard return values in ParkingLot. In class ConcreteParkingLot, the only one important field must be defined. Beyond that, you can define any attributes that you think are important.

Field:

private List<Car> cars
Contain all cars, including all different types such as Large Car, Small Car or other arbitrary subclass of Car.

5. You can add other Classes that you think are necessary.

Other Important parameters and Test cases

There are several initial parameters that need to mention to you, where to define those parameters are determined by your design.

The initial Time is 00:00, and we can make sure that the time cannot be exceeded 24 hours in this assignment.
When we mentions the current Time in this assignment, which means the current time of parking in our assignment, but not the actual time in the real world.
We can make sure that the test cases of plate numbers for each arriving car are all 5-digital numbers.
The original value of the plate number of car is "粤B" + those 5-digital numbers.
For example:

Time time1 = new Time(12, 45);
Car LargeCar = new LargeCar("11111", time1);
Car smallCar = new SmallCar("22222", time1);
System.out.println(LargeCar);
System.out.println(smallCar);
/*
LargeCar 粤B11111 12:45
SmallCar 粤B22222 12:45 deducted
*/
The original value of deduction of small car is determined by whether its plate number is an even number. If it is an even number, deduction is true, otherwise deduction is false.
For example:

SmallCar 粤B11110 deducted
SmallCar 粤B11112 deducted
SmallCar 粤B11116 deducted
SmallCar 粤B11117
SmallCar 粤B12321
SmallCar 粤B12345
If the count of current car equals to the capacity of the type of current car, the car cannot drive into the parking lot. For example, if the capacity of "SmallCar" is 5, and the current count of "SmallCar" in parking lot is 4, now there are 3 "SmallCar" (22222, 33333, 44444) want to drive in, in this case, only 22222 can drive in but other two cannot.
We can make sure that, in our test cases, the cars which want to drive out of the parking lots are all in the parking lot.
(Bonus Part) How to instantiate an object for specific Class object? You can try following code.

Class clz = SmallCar.class;
try {
SmallCar smallCar=(SmallCar) clz.newInstance();
smallCar.setPlateNumber("99990");
System.out.println(smallCar);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
/*
SmallCar 粤B99990 null deducted
*/
We can make sure that, in our test cases, all subclasses of Car contain a constructor with no parameter.

(Bonus part) In java programming language, Class<? extents Car> contains Car.class and the Class type of its subclasses. But in our assignment, we can make sure that, in our test cases, only the Class type of subclasses of Car can be the parameters of following three methods:

public void addParkingSpot(Class<? extends Car> type, int count);
public String getParkingSpotInfo(Class<? extends Car> type);
public void driveInto(Class<? extends Car> type, String... plateNumbers);`

Other Requirements

For the whole project, you do not need to input anything. Please read carefully about what we will do in Client1 and the Client1LocalJudge. Other than that, you also need to read carefully about the annotations in ParkingLot.java, from which you can understand what to do in each abstract method.

Question2 Design Your ArrayList

General Description

Design your ArrayList that is similar to java.util.ArrayList.

Requirements

The name of class must be MyArrayList<T>
The max capacity of your ArrayList is 20
The structure inside must be an array
To extands a class such as java.util.List, java.util.ArrayList or java.util.LinkedList is not accepted.
Designing a field that is a subclass of Collection or List is not accepted.
Methods:

public void add(T t)
Appends the specified element to the end of this list. If your arraylist is full, the new element cannot be added.

public void add(T t, int index)
Inserts the specified element at the specified position(index) in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right. If your arraylist is full, the new element cannot be added.

public boolean isEmpty()
return true if this list contains no elements, otherwise return false.

public int size()
return the number of elements in this list.

public T get(int index)
return the element at the specified position(index) in this list.

You can add other attributes that you think is necessary,
but any subclasses of java.util.Collection or java.util.List cannot appear in your Class.
Other Requirements

For the whole project, you needn’t input anything. Please read carefully about what we would do in Client2 (The official test case is another Client.java class, which is similar to this one), and the sample output for those.)

Submission of Assignment

1. You should submit all the source code files (with an extension “.java”).

2. You need submit at least those java files “.java” Car.java, LargeCar.java, SmallCar.java, ParkingLot.java, ConcreteParkingLot.java, Time.java, MyArrayList.java

3. You should submit all source code directly into your sakai system, do not compress them into one folder.

4. No Chinese characters are allowed to appear in your code.

5. No package included.

6. The output must strictly follow the description and the sample in this document and the Junit Test, and you can only get points for each task only when you pass the test case.

7. The assignment should be submitted before the deadline (Dec. 8th). Late submissions within 24 hours after the deadline (even a few minutes) will incur a 50% penalty, meaning that you can only get 50% of the score, which you could get if the assignment was submitted before the latest deadline. Assignments submitted after the latest deadline will not be graded (meaning your will get a zero for the assignment).

8. You will GET A ZERO if one of the following happens:

8.1 File name is not identical to the requirement

8.2 Compilation fail

8.3 Plagiarism

因为专业,所以值得信赖。如有需要,请加QQ99515681  微信:codehelp

以上是关于CS102A 2019的主要内容,如果未能解决你的问题,请参考以下文章

CS102A Fall 2019 Project:

Stats 102A HW4

题解 AT4164 [ABC102A] Multiple of 2 and N

SAP在提折旧时的错误 在测试时系统报了一个错误: 102A 科目 17020400 不是调整科目 。

vs2019打开cs文件老卡

CS560/460 Spring 2019