Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439

Computer Science Courses

COMP2100

Related sites

COMP 2100/2500/6442: Lab 2 - Tools for Software Development

The objective of this lab is to master the use of practicing revision control with git. The mini-test aims to evaluate your ability to complete some basic tasks along with further sharpening your Java programming skills.

Pre-lab Tasks - Mastering key tools [1 mark]

The first 10 minutes of the lab session time may be spent by your tutor to mark pre-lab tasks.

GIT

Using the command line on a Linux machine:

Mini-test - Java Programming [3 marks]

Guidelines

Your tutor will select one problem at random from the four options below and ask you to complete it correctly in the duration of the lab time. You may ask your tutor for a problem as soon as your pre-lab excercise is marked off. Start coding as soon as you are handed a problem!

In order to attain full marks, your solution must be correct. Your tutor may also decide to award some marks for a good attempt, in case of an incorrect or unfinished solution.

Remember, this is an individual exercise and must not be attempted collaboratively. However, feel free to discuss solutions to these problems with your colleagues before you attend this lab session.

Problem 1

Print out n using a recursive function. A fibonacci number is calculated by adding the previous two numbers in the series. A fibonacci series starts with 0, 1. The program must accept as input the value of n. For example, given n=6, the program must print 0, 1, 1, 2, 3, 5. The minimum value of n is 2.

Problem 2

Create an interface called TextDraw that has a method signature "void draw();". Create two classes, one called Box and the other Triangle. Both must implement the TextDraw interface. The draw() method in Box must draw a box to standard out using the '#' character. Whereas, Triangle triangle must draw a triangle. Create a class called DemoTextDraw which only has a main() method that contains:
   TextDraw box = new Box();   TextDraw tri = new Triangle();   box.draw();   System.out.println("-------------------");   tri.draw():
This would output:
############------------------##########

Problem 3

Print the following quadrilateral pattern, where n depicts the maximum horizontal width. For example, if n=5, the following pattern is printed:
  # ######## ###  #

The program must accept n as input. Assume that n is an odd integer with values ranging between [3,15]

Problem 4

Create a class called Shape that has an abstract method signature "void draw();". Create two classes, one called Box and the other Triangle, both extending the Shape class. The draw() method in Box must draw a box to standard out using the '#' character. Whereas, Triangle must draw a triangle. Create a class called DemoTextDraw which only has a main() method that contains:
   Shape box = new Box();   Shape tri = new Triangle();   box.draw();   System.out.println("------------------");   tri.draw():
This would output:
############------------------##########

Updated:  20 May 2016 / Responsible Officer:   JavaScript must be enabled to display this email address. / Page Contact:   JavaScript must be enabled to display this email address. / Powered by: Snorkel 1.4

+61 2 6125 5111
The Australian National University, Canberra
CRICOS Provider : 00120C
ABN : 52 234 063 906