Java代写:BN108 Programming for Networking

代写Java基础作业,作业分为两个部分,练习基本的Java语法。

Assignment Description

This assignment focuses on programming basics, for loops, expressions, variables, and constants. Turn in two Java files and two class files as described below.

Part A: ASCII Art

Imagine that you have been hired by a firm that writes simple programs that convert text into artistic pictures using any of the ASCII characters. In order to ensure that you are the right person for the job, you have been tasked to write a program that produces any text art (sometimes called “ASCII art”) picture of your liking.

Task requirements

Write a Java class named AsciiArt in a file named AsciiArt.java. Your program can produce any text picture you like, with the following restrictions and details:

  • The picture should be your own creation, not an ASCII image you found on the Internet or elsewhere.
  • The number of lines drawn should be at least 4 but no more than 200, and no more than 200 characters / line.
  • The picture should not include hateful, offensive, or otherwise inappropriate images.
  • The code should use at least one for loop or static method, but should not contain infinite loops.
  • If your Part A program compiles and runs successfully and meets the above constraints, it will receive the full 30 marks.

Part B: Unit Banner

Now that you have proven that you have what it takes to hire you, the second task allocated to you is to produce a specific text figure that is supposed to look like an advertisement banner with our unit, Programming for Networking, sitting on its side.

Write a Java class named Banner in a file named Banner.java. Your program should produce the following output:

You should exactly reproduce the format of this output. This includes having identical characters and spacing.

One way to write a Java program to draw this figure would be to write a System.out.println statement that prints each line of the figure. However, this solution would not receive full credit. A major part of this assignment is showing that you understand for loops.

Therefore, in lines that have repeated patterns of characters that vary in number from line to line, represent the lines and character patterns using nested for loops. It may help you to write pseudocode and tables to understand the output patterns, as described in the lecture.

Another significant component of this assignment is the task of generalizing the program using a class constant that can be changed to adjust the size of the figure as described on the next page

Class constant for figure’s size

You should create one (and only one) class constant to represent the size of the various pieces of the figure. Use 10 as the value of your constant. Your figure must be based on that exact value to receive full credit.
On any given execution your program will produce just one version of the figure. However, you should refer to the class constant throughout your code, so that by simply changing your constant’s value and recompiling, your program would produce a figure of a different size. Your program should scale correctly for any even constant value of 8 or greater. (We will not grade with an odd value or value below 8.)

To Get Started

This program is best completed in stages. We strongly recommend the following development strategy:

  1. Tables: Examine the output and write tables to discover the patterns of repeated characters on each line.
  2. Code without Constant: Completely write the Java code to draw the Banner at its default size of 10.
  3. Code with Constant: Add a constant to your code so that the Banner can scale to different sizes.

To summarize, you should not worry about the constant at first. Write an initial program without a constant, using loop tables or pseudocode to help you deduce the patterns in the output.