Question

In: Computer Science

Question: Not sure how to proceed with question below: In this task, task 2(a) will be...

Question: Not sure how to proceed with question below:

In this task, task 2(a) will be extended so that an array of five Person objects are created. Write the comma
separated values format of each object in separate lines in a file named persons.txt. Make use of the
toString() method of Person to obtain comma separated values.
Create a hyperlink pointing to the file persons.txt and include it on the task page. When the user clicks
on the link, the browser can then download it.

This is question 2a below: not need to be answered

Task 2: Chapter 14: page name=task2.php 40 marks
This task consists of two different subtasks.
(a) [15 marks]
Code a class named Person, which has three data properties to store the name, a telephone number and
an e‐mail address of a person.
The class must have a constructor to initialise all three data properties, three set methods and three get
methods to change and access the data properties of the class.
The class must also have a toString() method with an argument named $csv initialised to a default
boolean value true. By default, this function must return the value of data properties in comma separated
values (refer to Chapter 23, Section named ‘How to read and write CSV data’). On the other hand, if the
method is called with boolean value false, it returns a string representation of the data properties in a
different format (for example, see showAll() method in Section ‘How to loop through an object’s
properties’ in Chapter 14).
Create an object of the class Person, invoke all six set and get methods, and invoke toString() with
both boolean values. Display the results returned by toString()for both method calls.

Solutions

Expert Solution

I believe you are learning web development in PHP and OOPS at the same time, its great.

Why i said that, because my industrial exp says, web developers think using new frameworks and technologies is the only thing they should do.

Thats not good, i am happy that OOPS is your concern.

Now before answering, i would recommend you to be good with oops concepts

FIRST TASK, seems its independent but dont fall trap into the question lang, instead think unless u build a entity class for PERSON, how can you manage your task page,

Infact managing task page is just piece of cake,

Main thing here is how to design class PERSON thats your second task.

Lets work on it.

Now build a class with attributes given.

Class Person{

Private String name,

Private Long telephone,

Private String email,

//constructor to intialise,

Person(String name, String email, Long telephone) {

This. Name =name,

This. Email=email,

This. Telephone =telephone

}

//now gettters setters,

Public void setEmail(String Email) {

This email =email

}

Public void setName(String name) {

This.name =name

}

Public void setTelephone(Long telephone ) {

This telephone =telephone

}

Public void getName(){

Return this. Name

}

,

Public Void getEmail () {

Return this email

}

Public void getTelephone() {

Return this. Telephone

}

Public toString(csv = True) {

Now if you call this method with false value

Return string representation of data values in txt file

Otherwise,

Return comma separated values

}

}

Now to read text file, check out

<?php
$file = fopen("test.txt","r");
echo fgets($file);
fclose($file);
?>

This part is easy go through w3schools you will get it.

Now make another class Test, where you should intialize 5 objects of class person

This is it, its an pseudo code implementation, of requirements, good thing about pseudocode is you can develop your logic in any langugae

As it is said, pseudocode never rusts.

Viola, congratulations you have learned how to generate pseudocode for OOPS programming.

I would suggest, leanr oops from geeksforgeeks you will be a better programmer.

Happy learning ??


Related Solutions

PART A Task 1 – Prepare the Approval to Proceed Document Note: This task is to...
PART A Task 1 – Prepare the Approval to Proceed Document Note: This task is to take the place of Element 1 – Establish Project 1 from BSBPMG521 – Manage Project Integration. You are to complete the Approval to Proceed template carefully as it outlines the project parameters that you are to work within. If this is an active project, then you should complete this with your project sponsor. If not, then you will have to complete it yourself. This...
The question below is very long and I am not sure how to answer some of...
The question below is very long and I am not sure how to answer some of the questions. How much energy is needed for normal breathing? and How might this change with lung disease? how the ingredients in tobacco smoke damage/impair the respiratory system? What brain region controls respiration? What gas do the respiratory centers of the brain detect? How does this affect the respiration rate??
Task #3 Experimenting with an array of random integers (Week 2) Make sure that the following...
Task #3 Experimenting with an array of random integers (Week 2) Make sure that the following 3 experiments are done repeatedly by generating a new set of integers to fill the array. For this iterate 10 times and observe results for consistency. • Make the array size reasonably large (say a thousand) and an even number. • Choose the version of nextInt() that allows you to set a cap on the random integers generated (set it to a few thousands,...
Task 2 . . . . . . . . . . . . . ....
Task 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Five batch jobs, A through E, arrive at a computer at essentially...
The question below is fill-in-the-blank. Be sure that you follow the instructions since it is computer...
The question below is fill-in-the-blank. Be sure that you follow the instructions since it is computer graded. Either fill in the exact value you get from StatCrunch (no rounding) OR write your answer selection exactly as it is written. A soft-drink company is conducting research to select a new design for the can. A random sample of participants has been selected. Instead of a typical taste test with two different sodas, they gave each participant the same soda in two...
I am not even sure what the question is for the problem below, but I have...
I am not even sure what the question is for the problem below, but I have highlighted what I think the question is further down: Let v = (v1, v2) and w = (w1, w2) be vectors in 2 space. The Scalar Product of v and whose notation is v (dot) w, is defined as follows: V (dot) w : = v1*w1 + v2 *w2 The scalar product (aka inner product, or dot product) Scalar product of 2 vectors in...
Hi! I have a homework question I'm not sure if I'm doing it correctly. Below is...
Hi! I have a homework question I'm not sure if I'm doing it correctly. Below is the information from the question and my answer in bold. Glass Company makes glass orders based on the customer specifications, so the company uses job costing to track costs. The company uses direct labor hours as the cost driver for manufacturing overhead application. Manufacturing overhead costs for the year:        $787,500 Usage of direct labor hours for the year:               225,000 Beginning Work-in-process, March 1 (Job 57)      $80,000 Beginning...
Task: Write a program that creates a class Apple and a tester to make sure the...
Task: Write a program that creates a class Apple and a tester to make sure the Apple class is crisp and delicious. Instructions: First create a class called Apple  The class Apple DOES NOT HAVE a main method  Some of the attributes of Apple are o Type: A string that describes the apple. It may only be of the following types:  Red Delicious  Golden Delicious  Gala  Granny Smith o Weight: A decimal value representing...
(MUST BE DONE IN C (NOT C++)) In this task, you will have to make sure...
(MUST BE DONE IN C (NOT C++)) In this task, you will have to make sure you understood the concept of “the dot” in programming. Go ahead and declare an array of characters with a default length (whichever length you want, it's fine). Next, you want to ask the user for a phrase and store the characters in your array, but before you do that, ask the user for an estimated length of the array. If the length given is...
TASK This task is an individual assignment. Choose ONE of the types of speech below and...
TASK This task is an individual assignment. Choose ONE of the types of speech below and prepare a speech on the topic: EDUCATION 1) Informative OR 2) Persuasive Delivering an effective speech is a skill that needs to be developed especially for those with job tasks involving speeches like teachers, sales person, lawyers and many others. Either you are delivering an informative speech or a persuasive one, you will need to prepare your speech text.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT