Java代写:CS2360 Pattern Matching with a Wild Card

代写Java程序,实现通配符匹配。

Your task

A pattern matches a list if the list contains the pattern. For example, if a pattern is 34 and a list is 123456, there is a match between the pattern and list. A wild card is a pattern with a hidden digit (*), which can match to none or any single digit in a list. For example, if a pattern is 3*5 and a list is 12345678, there is one match between the pattern and list (i.e., 345).

Write a program to check whether a pattern matches a list, and output 1) the number of matches, 2) all the matches, and 3) the frequency of each match. Note that a pattern can have none or any number of hidden digits.

Your program should prompt the user to enter a list of digits (from 1 to 9) as an array of integers and a pattern as an integer. For pattern, use the digit ‘0’ to represent a hidden digit or *. For list, the first number in the list indicates the number of the elements in the list.

Sample output

The underline characters are input by the user.

Marking scheme

Programming Skill

  • You should use methods to make your program readable.

Program Correctness

The total mark is 70%. Mark will be allocated depending on the level of difficulty your program can handle.

Difficulty level I

Your program can handle a pattern with at most three digits, including one of the digits as the hidden digit. See samples1, 2 and 3 for examples.

Difficulty level II

Your program can handle a pattern with at most four digits, including two of the digits as the hidden digits. See sample 4 for example.

Difficulty level III

Your program can handle a pattern with at most 41 digits, and with at most 39 hidden digits. See sample 5 for example.

Advice

Concentrate on easy and normal samples first (difficulty level I)! Samples 4 and 5 (levels II & III) are not easy, but students expect to receive grade A or above should attempt.

Submission Guidelines

How to name my files?

Source Program: P1xxxxxxxx.java (xxxxxxxx is your student number)
Bytecode file: P1xxxxxxxx.class (xxxxxxxx is your student number)
(If your student number is 50259415, your filenames should be P150259415.java and P150259415.class)

What files do I need to submit?

  • A single zip file (by Winzip) named as xxxxxxxx.zip for submission. There should be 2 files in the zip file, one source program and one bytecode.
  • The source program should be named as: P1xxxxxxxx.java
  • The Java bytecode file should be named as: P1xxxxxxxx.class

(Note: xxxxxxxx is your eight digit student number)

What if I do not follow the suggested filenames (e.g., xxxxxxxxA.java)?

  • Your assignment may not be marked.

What is “Programming Skills”?

  • Document your source programs properly (e.g., put appropriate comments at appropriate places in your source programs)
  • Name the variables in the meaningful ways
  • Use proper indentation
  • Your programs are well designed and easily readable

How do you mark my assignment?

  • For each problem, we have several test cases. If your .class program gives correct answers to all the test cases, you get full marks for “Program correction”
  • If your program does not show correct answers, some (or all) marks will be deducted depending on the mistakes/errors you make
  • If your program has “compilation errors”, at least half marks will be deducted.
  • We also also mark your “programming skills”.

What else I should know?

Each source program must start with the following comments:

1
2
3
4
// Name: (Your name)
// Student ID: (Your student ID)
// Lab section: (Your lab session) (e.g., T01)
// Please delete your package line (for example: package assignment2;) before submission.