Sie sind auf Seite 1von 2

HET755

Tutorial (section 3)
Work on unfinished last week’s Lab exercises.

Input
Review input from keyboard – use Scanner (see last week’s Lab exercises)

Command-line input: download sample programs from Blackboard. Compile and run them.
(see slides 40-43 of lecture 3)

Classes and Objects

Review the sample code: BankAccount.java and Bank.java in last week’s Lab

Task I
Create a new class Student which has the following variables in it.

Name, Registration number, Course and Age

The class should have a constructor that initializes the name, Registration number and Age. The
course could be assigned later on by calling a function setCourse( ) that sets the value of course.
This function should have a parameter for accepting the value of course.

The class student must have functions showAge (), showCourse ( ).

The output of the shaowAge should be like: Hello John, you are 21 years old.
The output of showCource should be like: Hello John you are registered in MS Networks.

Use the class Student in another program by creating an object of the Student class. Call functions
of the Student class from that object.

Task II
Type the class Dotter in notepad and compile it. Type the other class DriveDotter in notepad and
compile and run it. The DriveDotter class uses Dotter class objects. Add one more mode that
prints $

public class Dotter {


char mode; public class DriveDotter {
public Dotter(char m){
mode = m; public static void
} main(String[] args) {
public void drawDots() {
if (mode == 's') Dotter d = new Dotter('s');
System.out.println("*");
if (mode == 'd') d.drawDots();
System.out.println("-"); d.setmode('d');
} d.drawDots();
d.setmode('s');
public void setmode(char m) { d.drawDots();
mode = m; }
} }
}

1
HET755

SMTP Sending an Email via Telnet (See last week’s Lab)

Add CC and BCC:


It is important to note here that SMTP does not have a BCC or a CC command. You
can use the command “RCPT TO:” to send your email to BCC and CC email
addresses.
Multiple comma separated addresses are also allowed.

Open a command prompt.


Now type: telnet mail.swin.edu.au 25 <ret>
Type the following commands:
HELO <your mail domain> <ret>
for example HELO swin.edu.au
MAIL FROM: <full email address><ret>
for example MAIL FROM: 1234567@student. swin.edu.au
RCPT TO: < who you want to send to/cc to /bcc to> <ret>
examples:
RCPT TO: peter@gamil.com
RCPT TO: ccperson@hotmail.com
RCPT TO: bccperson@yahoo.com
DATA<ret>
Now Type: <message> for example,
. Subject:Hi
CC: ccperson@hotmail
How are you?
.

QUIT<ret>
Return: Connection to host lost.

Das könnte Ihnen auch gefallen